ortools.constraint_solver.pywrapcp

   1# This file was automatically generated by SWIG (https://www.swig.org).
   2# Version 4.1.1
   3#
   4# Do not make changes to this file unless you know what you are doing - modify
   5# the SWIG interface file instead.
   6
   7from sys import version_info as _swig_python_version_info
   8# Import the low-level C/C++ module
   9if __package__ or "." in __name__:
  10    from . import _pywrapcp
  11else:
  12    import _pywrapcp
  13
  14try:
  15    import builtins as __builtin__
  16except ImportError:
  17    import __builtin__
  18
  19def _swig_repr(self):
  20    try:
  21        strthis = "proxy of " + self.this.__repr__()
  22    except __builtin__.Exception:
  23        strthis = ""
  24    return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
  25
  26
  27def _swig_setattr_nondynamic_instance_variable(set):
  28    def set_instance_attr(self, name, value):
  29        if name == "this":
  30            set(self, name, value)
  31        elif name == "thisown":
  32            self.this.own(value)
  33        elif hasattr(self, name) and isinstance(getattr(type(self), name), property):
  34            set(self, name, value)
  35        else:
  36            raise AttributeError("You cannot add instance attributes to %s" % self)
  37    return set_instance_attr
  38
  39
  40def _swig_setattr_nondynamic_class_variable(set):
  41    def set_class_attr(cls, name, value):
  42        if hasattr(cls, name) and not isinstance(getattr(cls, name), property):
  43            set(cls, name, value)
  44        else:
  45            raise AttributeError("You cannot add class attributes to %s" % cls)
  46    return set_class_attr
  47
  48
  49def _swig_add_metaclass(metaclass):
  50    """Class decorator for adding a metaclass to a SWIG wrapped class - a slimmed down version of six.add_metaclass"""
  51    def wrapper(cls):
  52        return metaclass(cls.__name__, cls.__bases__, cls.__dict__.copy())
  53    return wrapper
  54
  55
  56class _SwigNonDynamicMeta(type):
  57    """Meta class to enforce nondynamic attributes (no new attributes) for a class"""
  58    __setattr__ = _swig_setattr_nondynamic_class_variable(type.__setattr__)
  59
  60
  61import weakref
  62
  63class DefaultPhaseParameters(object):
  64    r"""
  65    This struct holds all parameters for the default search.
  66    DefaultPhaseParameters is only used by Solver::MakeDefaultPhase methods.
  67    Note this is for advanced users only.
  68    """
  69
  70    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
  71    __repr__ = _swig_repr
  72    CHOOSE_MAX_SUM_IMPACT = _pywrapcp.DefaultPhaseParameters_CHOOSE_MAX_SUM_IMPACT
  73    CHOOSE_MAX_AVERAGE_IMPACT = _pywrapcp.DefaultPhaseParameters_CHOOSE_MAX_AVERAGE_IMPACT
  74    CHOOSE_MAX_VALUE_IMPACT = _pywrapcp.DefaultPhaseParameters_CHOOSE_MAX_VALUE_IMPACT
  75    SELECT_MIN_IMPACT = _pywrapcp.DefaultPhaseParameters_SELECT_MIN_IMPACT
  76    SELECT_MAX_IMPACT = _pywrapcp.DefaultPhaseParameters_SELECT_MAX_IMPACT
  77    NONE = _pywrapcp.DefaultPhaseParameters_NONE
  78    NORMAL = _pywrapcp.DefaultPhaseParameters_NORMAL
  79    VERBOSE = _pywrapcp.DefaultPhaseParameters_VERBOSE
  80    var_selection_schema = property(_pywrapcp.DefaultPhaseParameters_var_selection_schema_get, _pywrapcp.DefaultPhaseParameters_var_selection_schema_set, doc=r"""
  81    This parameter describes how the next variable to instantiate
  82    will be chosen.
  83    """)
  84    value_selection_schema = property(_pywrapcp.DefaultPhaseParameters_value_selection_schema_get, _pywrapcp.DefaultPhaseParameters_value_selection_schema_set, doc=r""" This parameter describes which value to select for a given var.""")
  85    initialization_splits = property(_pywrapcp.DefaultPhaseParameters_initialization_splits_get, _pywrapcp.DefaultPhaseParameters_initialization_splits_set, doc=r"""
  86    Maximum number of intervals that the initialization of impacts will scan
  87    per variable.
  88    """)
  89    run_all_heuristics = property(_pywrapcp.DefaultPhaseParameters_run_all_heuristics_get, _pywrapcp.DefaultPhaseParameters_run_all_heuristics_set, doc=r"""
  90    The default phase will run heuristics periodically. This parameter
  91    indicates if we should run all heuristics, or a randomly selected
  92    one.
  93    """)
  94    heuristic_period = property(_pywrapcp.DefaultPhaseParameters_heuristic_period_get, _pywrapcp.DefaultPhaseParameters_heuristic_period_set, doc=r"""
  95    The distance in nodes between each run of the heuristics. A
  96    negative or null value will mean that we will not run heuristics
  97    at all.
  98    """)
  99    heuristic_num_failures_limit = property(_pywrapcp.DefaultPhaseParameters_heuristic_num_failures_limit_get, _pywrapcp.DefaultPhaseParameters_heuristic_num_failures_limit_set, doc=r""" The failure limit for each heuristic that we run.""")
 100    persistent_impact = property(_pywrapcp.DefaultPhaseParameters_persistent_impact_get, _pywrapcp.DefaultPhaseParameters_persistent_impact_set, doc=r"""
 101    Whether to keep the impact from the first search for other searches,
 102    or to recompute the impact for each new search.
 103    """)
 104    random_seed = property(_pywrapcp.DefaultPhaseParameters_random_seed_get, _pywrapcp.DefaultPhaseParameters_random_seed_set, doc=r""" Seed used to initialize the random part in some heuristics.""")
 105    display_level = property(_pywrapcp.DefaultPhaseParameters_display_level_get, _pywrapcp.DefaultPhaseParameters_display_level_set, doc=r"""
 106    This represents the amount of information displayed by the default search.
 107    NONE means no display, VERBOSE means extra information.
 108    """)
 109    decision_builder = property(_pywrapcp.DefaultPhaseParameters_decision_builder_get, _pywrapcp.DefaultPhaseParameters_decision_builder_set, doc=r""" When defined, this overrides the default impact based decision builder.""")
 110
 111    def __init__(self):
 112        _pywrapcp.DefaultPhaseParameters_swiginit(self, _pywrapcp.new_DefaultPhaseParameters())
 113    __swig_destroy__ = _pywrapcp.delete_DefaultPhaseParameters
 114
 115# Register DefaultPhaseParameters in _pywrapcp:
 116_pywrapcp.DefaultPhaseParameters_swigregister(DefaultPhaseParameters)
 117class Solver(object):
 118    r"""
 119    Solver Class
 120
 121    A solver represents the main computation engine. It implements the entire
 122    range of Constraint Programming protocols:
 123      - Reversibility
 124      - Propagation
 125      - Search
 126
 127    Usually, Constraint Programming code consists of
 128      - the creation of the Solver,
 129      - the creation of the decision variables of the model,
 130      - the creation of the constraints of the model and their addition to the
 131        solver() through the AddConstraint() method,
 132      - the creation of the main DecisionBuilder class,
 133      - the launch of the solve() method with the decision builder.
 134
 135    For the time being, Solver is neither MT_SAFE nor MT_HOT.
 136    """
 137
 138    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
 139    __repr__ = _swig_repr
 140    INT_VAR_DEFAULT = _pywrapcp.Solver_INT_VAR_DEFAULT
 141    r""" The default behavior is CHOOSE_FIRST_UNBOUND."""
 142    INT_VAR_SIMPLE = _pywrapcp.Solver_INT_VAR_SIMPLE
 143    r""" The simple selection is CHOOSE_FIRST_UNBOUND."""
 144    CHOOSE_FIRST_UNBOUND = _pywrapcp.Solver_CHOOSE_FIRST_UNBOUND
 145    r"""
 146    Select the first unbound variable.
 147    Variables are considered in the order of the vector of IntVars used
 148    to create the selector.
 149    """
 150    CHOOSE_RANDOM = _pywrapcp.Solver_CHOOSE_RANDOM
 151    r""" Randomly select one of the remaining unbound variables."""
 152    CHOOSE_MIN_SIZE_LOWEST_MIN = _pywrapcp.Solver_CHOOSE_MIN_SIZE_LOWEST_MIN
 153    r"""
 154    Among unbound variables, select the variable with the smallest size,
 155    i.e., the smallest number of possible values.
 156    In case of a tie, the selected variables is the one with the lowest min
 157    value.
 158    In case of a tie, the first one is selected, first being defined by the
 159    order in the vector of IntVars used to create the selector.
 160    """
 161    CHOOSE_MIN_SIZE_HIGHEST_MIN = _pywrapcp.Solver_CHOOSE_MIN_SIZE_HIGHEST_MIN
 162    r"""
 163    Among unbound variables, select the variable with the smallest size,
 164    i.e., the smallest number of possible values.
 165    In case of a tie, the selected variable is the one with the highest min
 166    value.
 167    In case of a tie, the first one is selected, first being defined by the
 168    order in the vector of IntVars used to create the selector.
 169    """
 170    CHOOSE_MIN_SIZE_LOWEST_MAX = _pywrapcp.Solver_CHOOSE_MIN_SIZE_LOWEST_MAX
 171    r"""
 172    Among unbound variables, select the variable with the smallest size,
 173    i.e., the smallest number of possible values.
 174    In case of a tie, the selected variables is the one with the lowest max
 175    value.
 176    In case of a tie, the first one is selected, first being defined by the
 177    order in the vector of IntVars used to create the selector.
 178    """
 179    CHOOSE_MIN_SIZE_HIGHEST_MAX = _pywrapcp.Solver_CHOOSE_MIN_SIZE_HIGHEST_MAX
 180    r"""
 181    Among unbound variables, select the variable with the smallest size,
 182    i.e., the smallest number of possible values.
 183    In case of a tie, the selected variable is the one with the highest max
 184    value.
 185    In case of a tie, the first one is selected, first being defined by the
 186    order in the vector of IntVars used to create the selector.
 187    """
 188    CHOOSE_LOWEST_MIN = _pywrapcp.Solver_CHOOSE_LOWEST_MIN
 189    r"""
 190    Among unbound variables, select the variable with the smallest minimal
 191    value.
 192    In case of a tie, the first one is selected, "first" defined by the
 193    order in the vector of IntVars used to create the selector.
 194    """
 195    CHOOSE_HIGHEST_MAX = _pywrapcp.Solver_CHOOSE_HIGHEST_MAX
 196    r"""
 197    Among unbound variables, select the variable with the highest maximal
 198    value.
 199    In case of a tie, the first one is selected, first being defined by the
 200    order in the vector of IntVars used to create the selector.
 201    """
 202    CHOOSE_MIN_SIZE = _pywrapcp.Solver_CHOOSE_MIN_SIZE
 203    r"""
 204    Among unbound variables, select the variable with the smallest size.
 205    In case of a tie, the first one is selected, first being defined by the
 206    order in the vector of IntVars used to create the selector.
 207    """
 208    CHOOSE_MAX_SIZE = _pywrapcp.Solver_CHOOSE_MAX_SIZE
 209    r"""
 210    Among unbound variables, select the variable with the highest size.
 211    In case of a tie, the first one is selected, first being defined by the
 212    order in the vector of IntVars used to create the selector.
 213    """
 214    CHOOSE_MAX_REGRET_ON_MIN = _pywrapcp.Solver_CHOOSE_MAX_REGRET_ON_MIN
 215    r"""
 216    Among unbound variables, select the variable with the largest
 217    gap between the first and the second values of the domain.
 218    """
 219    CHOOSE_PATH = _pywrapcp.Solver_CHOOSE_PATH
 220    r"""
 221    Selects the next unbound variable on a path, the path being defined by
 222    the variables: var[i] corresponds to the index of the next of i.
 223    """
 224    INT_VALUE_DEFAULT = _pywrapcp.Solver_INT_VALUE_DEFAULT
 225    r""" The default behavior is ASSIGN_MIN_VALUE."""
 226    INT_VALUE_SIMPLE = _pywrapcp.Solver_INT_VALUE_SIMPLE
 227    r""" The simple selection is ASSIGN_MIN_VALUE."""
 228    ASSIGN_MIN_VALUE = _pywrapcp.Solver_ASSIGN_MIN_VALUE
 229    r""" Selects the min value of the selected variable."""
 230    ASSIGN_MAX_VALUE = _pywrapcp.Solver_ASSIGN_MAX_VALUE
 231    r""" Selects the max value of the selected variable."""
 232    ASSIGN_RANDOM_VALUE = _pywrapcp.Solver_ASSIGN_RANDOM_VALUE
 233    r""" Selects randomly one of the possible values of the selected variable."""
 234    ASSIGN_CENTER_VALUE = _pywrapcp.Solver_ASSIGN_CENTER_VALUE
 235    r"""
 236    Selects the first possible value which is the closest to the center
 237    of the domain of the selected variable.
 238    The center is defined as (min + max) / 2.
 239    """
 240    SPLIT_LOWER_HALF = _pywrapcp.Solver_SPLIT_LOWER_HALF
 241    r"""
 242    Split the domain in two around the center, and choose the lower
 243    part first.
 244    """
 245    SPLIT_UPPER_HALF = _pywrapcp.Solver_SPLIT_UPPER_HALF
 246    r"""
 247    Split the domain in two around the center, and choose the lower
 248    part first.
 249    """
 250    SEQUENCE_DEFAULT = _pywrapcp.Solver_SEQUENCE_DEFAULT
 251    SEQUENCE_SIMPLE = _pywrapcp.Solver_SEQUENCE_SIMPLE
 252    CHOOSE_MIN_SLACK_RANK_FORWARD = _pywrapcp.Solver_CHOOSE_MIN_SLACK_RANK_FORWARD
 253    CHOOSE_RANDOM_RANK_FORWARD = _pywrapcp.Solver_CHOOSE_RANDOM_RANK_FORWARD
 254    INTERVAL_DEFAULT = _pywrapcp.Solver_INTERVAL_DEFAULT
 255    r""" The default is INTERVAL_SET_TIMES_FORWARD."""
 256    INTERVAL_SIMPLE = _pywrapcp.Solver_INTERVAL_SIMPLE
 257    r""" The simple is INTERVAL_SET_TIMES_FORWARD."""
 258    INTERVAL_SET_TIMES_FORWARD = _pywrapcp.Solver_INTERVAL_SET_TIMES_FORWARD
 259    r"""
 260    Selects the variable with the lowest starting time of all variables,
 261    and fixes its starting time to this lowest value.
 262    """
 263    INTERVAL_SET_TIMES_BACKWARD = _pywrapcp.Solver_INTERVAL_SET_TIMES_BACKWARD
 264    r"""
 265    Selects the variable with the highest ending time of all variables,
 266    and fixes the ending time to this highest values.
 267    """
 268    TWOOPT = _pywrapcp.Solver_TWOOPT
 269    r"""
 270    Operator which reverses a sub-chain of a path. It is called TwoOpt
 271    because it breaks two arcs on the path; resulting paths are called
 272    two-optimal.
 273    Possible neighbors for the path 1 -> 2 -> 3 -> 4 -> 5
 274    (where (1, 5) are first and last nodes of the path and can therefore not
 275    be moved):
 276      1 -> [3 -> 2] -> 4  -> 5
 277      1 -> [4 -> 3  -> 2] -> 5
 278      1 ->  2 -> [4 -> 3] -> 5
 279    """
 280    OROPT = _pywrapcp.Solver_OROPT
 281    r"""
 282    Relocate: OROPT and RELOCATE.
 283    Operator which moves a sub-chain of a path to another position; the
 284    specified chain length is the fixed length of the chains being moved.
 285    When this length is 1, the operator simply moves a node to another
 286    position.
 287    Possible neighbors for the path 1 -> 2 -> 3 -> 4 -> 5, for a chain
 288    length of 2 (where (1, 5) are first and last nodes of the path and can
 289    therefore not be moved):
 290      1 ->  4 -> [2 -> 3] -> 5
 291      1 -> [3 -> 4] -> 2  -> 5
 292
 293    Using Relocate with chain lengths of 1, 2 and 3 together is equivalent
 294    to the OrOpt operator on a path. The OrOpt operator is a limited
 295     version of 3Opt (breaks 3 arcs on a path).
 296    """
 297    RELOCATE = _pywrapcp.Solver_RELOCATE
 298    r""" Relocate neighborhood with length of 1 (see OROPT comment)."""
 299    EXCHANGE = _pywrapcp.Solver_EXCHANGE
 300    r"""
 301    Operator which exchanges the positions of two nodes.
 302    Possible neighbors for the path 1 -> 2 -> 3 -> 4 -> 5
 303    (where (1, 5) are first and last nodes of the path and can therefore not
 304    be moved):
 305      1 -> [3] -> [2] ->  4  -> 5
 306      1 -> [4] ->  3  -> [2] -> 5
 307      1 ->  2  -> [4] -> [3] -> 5
 308    """
 309    CROSS = _pywrapcp.Solver_CROSS
 310    r"""
 311    Operator which cross exchanges the starting chains of 2 paths, including
 312    exchanging the whole paths.
 313    First and last nodes are not moved.
 314    Possible neighbors for the paths 1 -> 2 -> 3 -> 4 -> 5 and 6 -> 7 -> 8
 315    (where (1, 5) and (6, 8) are first and last nodes of the paths and can
 316    therefore not be moved):
 317      1 -> [7] -> 3 -> 4 -> 5  6 -> [2] -> 8
 318      1 -> [7] -> 4 -> 5       6 -> [2 -> 3] -> 8
 319      1 -> [7] -> 5            6 -> [2 -> 3 -> 4] -> 8
 320    """
 321    MAKEACTIVE = _pywrapcp.Solver_MAKEACTIVE
 322    r"""
 323    Operator which inserts an inactive node into a path.
 324    Possible neighbors for the path 1 -> 2 -> 3 -> 4 with 5 inactive
 325    (where 1 and 4 are first and last nodes of the path) are:
 326      1 -> [5] ->  2  ->  3  -> 4
 327      1 ->  2  -> [5] ->  3  -> 4
 328      1 ->  2  ->  3  -> [5] -> 4
 329    """
 330    MAKEINACTIVE = _pywrapcp.Solver_MAKEINACTIVE
 331    r"""
 332    Operator which makes path nodes inactive.
 333    Possible neighbors for the path 1 -> 2 -> 3 -> 4 (where 1 and 4 are
 334    first and last nodes of the path) are:
 335      1 -> 3 -> 4 with 2 inactive
 336      1 -> 2 -> 4 with 3 inactive
 337    """
 338    MAKECHAININACTIVE = _pywrapcp.Solver_MAKECHAININACTIVE
 339    r"""
 340    Operator which makes a "chain" of path nodes inactive.
 341    Possible neighbors for the path 1 -> 2 -> 3 -> 4 (where 1 and 4 are
 342    first and last nodes of the path) are:
 343      1 -> 3 -> 4 with 2 inactive
 344      1 -> 2 -> 4 with 3 inactive
 345      1 -> 4 with 2 and 3 inactive
 346    """
 347    SWAPACTIVE = _pywrapcp.Solver_SWAPACTIVE
 348    r"""
 349    Operator which replaces an active node by an inactive one.
 350    Possible neighbors for the path 1 -> 2 -> 3 -> 4 with 5 inactive
 351    (where 1 and 4 are first and last nodes of the path) are:
 352      1 -> [5] ->  3  -> 4 with 2 inactive
 353      1 ->  2  -> [5] -> 4 with 3 inactive
 354    """
 355    EXTENDEDSWAPACTIVE = _pywrapcp.Solver_EXTENDEDSWAPACTIVE
 356    r"""
 357    Operator which makes an inactive node active and an active one inactive.
 358    It is similar to SwapActiveOperator except that it tries to insert the
 359    inactive node in all possible positions instead of just the position of
 360    the node made inactive.
 361    Possible neighbors for the path 1 -> 2 -> 3 -> 4 with 5 inactive
 362    (where 1 and 4 are first and last nodes of the path) are:
 363      1 -> [5] ->  3  -> 4 with 2 inactive
 364      1 ->  3  -> [5] -> 4 with 2 inactive
 365      1 -> [5] ->  2  -> 4 with 3 inactive
 366      1 ->  2  -> [5] -> 4 with 3 inactive
 367    """
 368    PATHLNS = _pywrapcp.Solver_PATHLNS
 369    r"""
 370    Operator which relaxes two sub-chains of three consecutive arcs each.
 371    Each sub-chain is defined by a start node and the next three arcs. Those
 372    six arcs are relaxed to build a new neighbor.
 373    PATHLNS explores all possible pairs of starting nodes and so defines
 374    n^2 neighbors, n being the number of nodes.
 375    Note that the two sub-chains can be part of the same path; they even may
 376    overlap.
 377    """
 378    FULLPATHLNS = _pywrapcp.Solver_FULLPATHLNS
 379    r"""
 380    Operator which relaxes one entire path and all inactive nodes, thus
 381    defining num_paths neighbors.
 382    """
 383    UNACTIVELNS = _pywrapcp.Solver_UNACTIVELNS
 384    r"""
 385    Operator which relaxes all inactive nodes and one sub-chain of six
 386    consecutive arcs. That way the path can be improved by inserting
 387    inactive nodes or swapping arcs.
 388    """
 389    INCREMENT = _pywrapcp.Solver_INCREMENT
 390    r"""
 391    Operator which defines one neighbor per variable. Each neighbor tries to
 392    increment by one the value of the corresponding variable. When a new
 393    solution is found the neighborhood is rebuilt from scratch, i.e., tries
 394    to increment values in the variable order.
 395    Consider for instance variables x and y. x is incremented one by one to
 396    its max, and when it is not possible to increment x anymore, y is
 397    incremented once. If this is a solution, then next neighbor tries to
 398    increment x.
 399    """
 400    DECREMENT = _pywrapcp.Solver_DECREMENT
 401    r"""
 402    Operator which defines a neighborhood to decrement values.
 403    The behavior is the same as INCREMENT, except values are decremented
 404    instead of incremented.
 405    """
 406    SIMPLELNS = _pywrapcp.Solver_SIMPLELNS
 407    r"""
 408    Operator which defines one neighbor per variable. Each neighbor relaxes
 409    one variable.
 410    When a new solution is found the neighborhood is rebuilt from scratch.
 411    Consider for instance variables x and y. First x is relaxed and the
 412    solver is looking for the best possible solution (with only x relaxed).
 413    Then y is relaxed, and the solver is looking for a new solution.
 414    If a new solution is found, then the next variable to be relaxed is x.
 415    """
 416    GE = _pywrapcp.Solver_GE
 417    r""" Move is accepted when the current objective value >= objective.Min."""
 418    LE = _pywrapcp.Solver_LE
 419    r""" Move is accepted when the current objective value <= objective.Max."""
 420    EQ = _pywrapcp.Solver_EQ
 421    r"""
 422    Move is accepted when the current objective value is in the interval
 423    objective.Min .. objective.Max.
 424    """
 425    DELAYED_PRIORITY = _pywrapcp.Solver_DELAYED_PRIORITY
 426    r"""
 427    DELAYED_PRIORITY is the lowest priority: Demons will be processed after
 428    VAR_PRIORITY and NORMAL_PRIORITY demons.
 429    """
 430    VAR_PRIORITY = _pywrapcp.Solver_VAR_PRIORITY
 431    r""" VAR_PRIORITY is between DELAYED_PRIORITY and NORMAL_PRIORITY."""
 432    NORMAL_PRIORITY = _pywrapcp.Solver_NORMAL_PRIORITY
 433    r""" NORMAL_PRIORITY is the highest priority: Demons will be processed first."""
 434
 435    def __init__(self, *args):
 436        _pywrapcp.Solver_swiginit(self, _pywrapcp.new_Solver(*args))
 437
 438        self.__python_constraints = []
 439
 440
 441
 442    __swig_destroy__ = _pywrapcp.delete_Solver
 443
 444    def Parameters(self):
 445        r""" Stored Parameters."""
 446        return _pywrapcp.Solver_Parameters(self)
 447
 448    @staticmethod
 449    def DefaultSolverParameters():
 450        r""" Create a ConstraintSolverParameters proto with all the default values."""
 451        return _pywrapcp.Solver_DefaultSolverParameters()
 452
 453    def AddConstraint(self, c):
 454        r"""
 455        Adds the constraint 'c' to the model.
 456
 457        After calling this method, and until there is a backtrack that undoes the
 458        addition, any assignment of variables to values must satisfy the given
 459        constraint in order to be considered feasible. There are two fairly
 460        different use cases:
 461
 462        - the most common use case is modeling: the given constraint is really
 463        part of the problem that the user is trying to solve. In this use case,
 464        AddConstraint is called outside of search (i.e., with state() ==
 465        OUTSIDE_SEARCH). Most users should only use AddConstraint in this
 466        way. In this case, the constraint will belong to the model forever: it
 467        cannot not be removed by backtracking.
 468
 469        - a rarer use case is that 'c' is not a real constraint of the model. It
 470        may be a constraint generated by a branching decision (a constraint whose
 471        goal is to restrict the search space), a symmetry breaking constraint (a
 472        constraint that does restrict the search space, but in a way that cannot
 473        have an impact on the quality of the solutions in the subtree), or an
 474        inferred constraint that, while having no semantic value to the model (it
 475        does not restrict the set of solutions), is worth having because we
 476        believe it may strengthen the propagation. In these cases, it happens
 477        that the constraint is added during the search (i.e., with state() ==
 478        IN_SEARCH or state() == IN_ROOT_NODE). When a constraint is
 479        added during a search, it applies only to the subtree of the search tree
 480        rooted at the current node, and will be automatically removed by
 481        backtracking.
 482
 483        This method does not take ownership of the constraint. If the constraint
 484        has been created by any factory method (Solver::MakeXXX), it will
 485        automatically be deleted. However, power users who implement their own
 486        constraints should do: solver.AddConstraint(solver.RevAlloc(new
 487        MyConstraint(...));
 488        """
 489        return _pywrapcp.Solver_AddConstraint(self, c)
 490
 491    def Solve(self, *args):
 492        return _pywrapcp.Solver_Solve(self, *args)
 493
 494    def NewSearch(self, *args):
 495        return _pywrapcp.Solver_NewSearch(self, *args)
 496
 497    def NextSolution(self):
 498        return _pywrapcp.Solver_NextSolution(self)
 499
 500    def RestartSearch(self):
 501        return _pywrapcp.Solver_RestartSearch(self)
 502
 503    def EndSearch(self):
 504        return _pywrapcp.Solver_EndSearch(self)
 505
 506    def SolveAndCommit(self, *args):
 507        return _pywrapcp.Solver_SolveAndCommit(self, *args)
 508
 509    def CheckAssignment(self, solution):
 510        r""" Checks whether the given assignment satisfies all relevant constraints."""
 511        return _pywrapcp.Solver_CheckAssignment(self, solution)
 512
 513    def CheckConstraint(self, ct):
 514        r"""
 515        Checks whether adding this constraint will lead to an immediate
 516        failure. It will return false if the model is already inconsistent, or if
 517        adding the constraint makes it inconsistent.
 518        """
 519        return _pywrapcp.Solver_CheckConstraint(self, ct)
 520
 521    def Fail(self):
 522        r""" Abandon the current branch in the search tree. A backtrack will follow."""
 523        return _pywrapcp.Solver_Fail(self)
 524
 525    @staticmethod
 526    def MemoryUsage():
 527        r""" Current memory usage in bytes"""
 528        return _pywrapcp.Solver_MemoryUsage()
 529
 530    def WallTime(self):
 531        r"""
 532        DEPRECATED: Use Now() instead.
 533        Time elapsed, in ms since the creation of the solver.
 534        """
 535        return _pywrapcp.Solver_WallTime(self)
 536
 537    def Branches(self):
 538        r""" The number of branches explored since the creation of the solver."""
 539        return _pywrapcp.Solver_Branches(self)
 540
 541    def Solutions(self):
 542        r""" The number of solutions found since the start of the search."""
 543        return _pywrapcp.Solver_Solutions(self)
 544
 545    def Failures(self):
 546        r""" The number of failures encountered since the creation of the solver."""
 547        return _pywrapcp.Solver_Failures(self)
 548
 549    def AcceptedNeighbors(self):
 550        r""" The number of accepted neighbors."""
 551        return _pywrapcp.Solver_AcceptedNeighbors(self)
 552
 553    def Stamp(self):
 554        r"""
 555        The stamp indicates how many moves in the search tree we have performed.
 556        It is useful to detect if we need to update same lazy structures.
 557        """
 558        return _pywrapcp.Solver_Stamp(self)
 559
 560    def FailStamp(self):
 561        r""" The fail_stamp() is incremented after each backtrack."""
 562        return _pywrapcp.Solver_FailStamp(self)
 563
 564    def IntVar(self, *args):
 565        r"""
 566        *Overload 1:*
 567        MakeIntVar will create the best range based int var for the bounds given.
 568
 569        |
 570
 571        *Overload 2:*
 572        MakeIntVar will create a variable with the given sparse domain.
 573
 574        |
 575
 576        *Overload 3:*
 577        MakeIntVar will create a variable with the given sparse domain.
 578
 579        |
 580
 581        *Overload 4:*
 582        MakeIntVar will create the best range based int var for the bounds given.
 583
 584        |
 585
 586        *Overload 5:*
 587        MakeIntVar will create a variable with the given sparse domain.
 588
 589        |
 590
 591        *Overload 6:*
 592        MakeIntVar will create a variable with the given sparse domain.
 593        """
 594        return _pywrapcp.Solver_IntVar(self, *args)
 595
 596    def BoolVar(self, *args):
 597        r"""
 598        *Overload 1:*
 599        MakeBoolVar will create a variable with a {0, 1} domain.
 600
 601        |
 602
 603        *Overload 2:*
 604        MakeBoolVar will create a variable with a {0, 1} domain.
 605        """
 606        return _pywrapcp.Solver_BoolVar(self, *args)
 607
 608    def IntConst(self, *args):
 609        r"""
 610        *Overload 1:*
 611        IntConst will create a constant expression.
 612
 613        |
 614
 615        *Overload 2:*
 616        IntConst will create a constant expression.
 617        """
 618        return _pywrapcp.Solver_IntConst(self, *args)
 619
 620    def Sum(self, vars):
 621        r""" sum of all vars."""
 622        return _pywrapcp.Solver_Sum(self, vars)
 623
 624    def ScalProd(self, *args):
 625        r"""
 626        *Overload 1:*
 627        scalar product
 628
 629        |
 630
 631        *Overload 2:*
 632        scalar product
 633        """
 634        return _pywrapcp.Solver_ScalProd(self, *args)
 635
 636    def MonotonicElement(self, values, increasing, index):
 637        r"""
 638        Function based element. The constraint takes ownership of the
 639        callback.  The callback must be monotonic. It must be able to
 640        cope with any possible value in the domain of 'index'
 641        (potentially negative ones too). Furtermore, monotonicity is not
 642        checked. Thus giving a non-monotonic function, or specifying an
 643        incorrect increasing parameter will result in undefined behavior.
 644        """
 645        return _pywrapcp.Solver_MonotonicElement(self, values, increasing, index)
 646
 647    def Element(self, *args):
 648        r"""
 649        *Overload 1:*
 650        values[index]
 651
 652        |
 653
 654        *Overload 2:*
 655        values[index]
 656
 657        |
 658
 659        *Overload 3:*
 660        Function-based element. The constraint takes ownership of the
 661        callback. The callback must be able to cope with any possible
 662        value in the domain of 'index' (potentially negative ones too).
 663
 664        |
 665
 666        *Overload 4:*
 667        2D version of function-based element expression, values(expr1, expr2).
 668
 669        |
 670
 671        *Overload 5:*
 672        vars[expr]
 673        """
 674        return _pywrapcp.Solver_Element(self, *args)
 675
 676    def IndexExpression(self, vars, value):
 677        r"""
 678        Returns the expression expr such that vars[expr] == value.
 679        It assumes that vars are all different.
 680        """
 681        return _pywrapcp.Solver_IndexExpression(self, vars, value)
 682
 683    def Min(self, *args):
 684        r"""
 685        *Overload 1:*
 686        std::min(vars)
 687
 688        |
 689
 690        *Overload 2:*
 691        std::min (left, right)
 692
 693        |
 694
 695        *Overload 3:*
 696        std::min(expr, value)
 697
 698        |
 699
 700        *Overload 4:*
 701        std::min(expr, value)
 702        """
 703        return _pywrapcp.Solver_Min(self, *args)
 704
 705    def Max(self, *args):
 706        r"""
 707        *Overload 1:*
 708        std::max(vars)
 709
 710        |
 711
 712        *Overload 2:*
 713        std::max(left, right)
 714
 715        |
 716
 717        *Overload 3:*
 718        std::max(expr, value)
 719
 720        |
 721
 722        *Overload 4:*
 723        std::max(expr, value)
 724        """
 725        return _pywrapcp.Solver_Max(self, *args)
 726
 727    def ConvexPiecewiseExpr(self, expr, early_cost, early_date, late_date, late_cost):
 728        r""" Convex piecewise function."""
 729        return _pywrapcp.Solver_ConvexPiecewiseExpr(self, expr, early_cost, early_date, late_date, late_cost)
 730
 731    def SemiContinuousExpr(self, expr, fixed_charge, step):
 732        r"""
 733        Semi continuous Expression (x <= 0 -> f(x) = 0; x > 0 -> f(x) = ax + b)
 734        a >= 0 and b >= 0
 735        """
 736        return _pywrapcp.Solver_SemiContinuousExpr(self, expr, fixed_charge, step)
 737
 738    def ConditionalExpression(self, condition, expr, unperformed_value):
 739        r""" Conditional Expr condition ? expr : unperformed_value"""
 740        return _pywrapcp.Solver_ConditionalExpression(self, condition, expr, unperformed_value)
 741
 742    def TrueConstraint(self):
 743        r""" This constraint always succeeds."""
 744        return _pywrapcp.Solver_TrueConstraint(self)
 745
 746    def FalseConstraint(self, *args):
 747        return _pywrapcp.Solver_FalseConstraint(self, *args)
 748
 749    def IsEqualCstCt(self, var, value, boolvar):
 750        r""" boolvar == (var == value)"""
 751        return _pywrapcp.Solver_IsEqualCstCt(self, var, value, boolvar)
 752
 753    def IsEqualCstVar(self, var, value):
 754        r""" status var of (var == value)"""
 755        return _pywrapcp.Solver_IsEqualCstVar(self, var, value)
 756
 757    def IsEqualCt(self, v1, v2, b):
 758        r""" b == (v1 == v2)"""
 759        return _pywrapcp.Solver_IsEqualCt(self, v1, v2, b)
 760
 761    def IsEqualVar(self, v1, v2):
 762        r""" status var of (v1 == v2)"""
 763        return _pywrapcp.Solver_IsEqualVar(self, v1, v2)
 764
 765    def IsDifferentCstCt(self, var, value, boolvar):
 766        r""" boolvar == (var != value)"""
 767        return _pywrapcp.Solver_IsDifferentCstCt(self, var, value, boolvar)
 768
 769    def IsDifferentCstVar(self, var, value):
 770        r""" status var of (var != value)"""
 771        return _pywrapcp.Solver_IsDifferentCstVar(self, var, value)
 772
 773    def IsDifferentVar(self, v1, v2):
 774        r""" status var of (v1 != v2)"""
 775        return _pywrapcp.Solver_IsDifferentVar(self, v1, v2)
 776
 777    def IsDifferentCt(self, v1, v2, b):
 778        r""" b == (v1 != v2)"""
 779        return _pywrapcp.Solver_IsDifferentCt(self, v1, v2, b)
 780
 781    def IsLessOrEqualCstCt(self, var, value, boolvar):
 782        r""" boolvar == (var <= value)"""
 783        return _pywrapcp.Solver_IsLessOrEqualCstCt(self, var, value, boolvar)
 784
 785    def IsLessOrEqualCstVar(self, var, value):
 786        r""" status var of (var <= value)"""
 787        return _pywrapcp.Solver_IsLessOrEqualCstVar(self, var, value)
 788
 789    def IsLessOrEqualVar(self, left, right):
 790        r""" status var of (left <= right)"""
 791        return _pywrapcp.Solver_IsLessOrEqualVar(self, left, right)
 792
 793    def IsLessOrEqualCt(self, left, right, b):
 794        r""" b == (left <= right)"""
 795        return _pywrapcp.Solver_IsLessOrEqualCt(self, left, right, b)
 796
 797    def IsGreaterOrEqualCstCt(self, var, value, boolvar):
 798        r""" boolvar == (var >= value)"""
 799        return _pywrapcp.Solver_IsGreaterOrEqualCstCt(self, var, value, boolvar)
 800
 801    def IsGreaterOrEqualCstVar(self, var, value):
 802        r""" status var of (var >= value)"""
 803        return _pywrapcp.Solver_IsGreaterOrEqualCstVar(self, var, value)
 804
 805    def IsGreaterOrEqualVar(self, left, right):
 806        r""" status var of (left >= right)"""
 807        return _pywrapcp.Solver_IsGreaterOrEqualVar(self, left, right)
 808
 809    def IsGreaterOrEqualCt(self, left, right, b):
 810        r""" b == (left >= right)"""
 811        return _pywrapcp.Solver_IsGreaterOrEqualCt(self, left, right, b)
 812
 813    def IsGreaterCstCt(self, v, c, b):
 814        r""" b == (v > c)"""
 815        return _pywrapcp.Solver_IsGreaterCstCt(self, v, c, b)
 816
 817    def IsGreaterCstVar(self, var, value):
 818        r""" status var of (var > value)"""
 819        return _pywrapcp.Solver_IsGreaterCstVar(self, var, value)
 820
 821    def IsGreaterVar(self, left, right):
 822        r""" status var of (left > right)"""
 823        return _pywrapcp.Solver_IsGreaterVar(self, left, right)
 824
 825    def IsGreaterCt(self, left, right, b):
 826        r""" b == (left > right)"""
 827        return _pywrapcp.Solver_IsGreaterCt(self, left, right, b)
 828
 829    def IsLessCstCt(self, v, c, b):
 830        r""" b == (v < c)"""
 831        return _pywrapcp.Solver_IsLessCstCt(self, v, c, b)
 832
 833    def IsLessCstVar(self, var, value):
 834        r""" status var of (var < value)"""
 835        return _pywrapcp.Solver_IsLessCstVar(self, var, value)
 836
 837    def IsLessVar(self, left, right):
 838        r""" status var of (left < right)"""
 839        return _pywrapcp.Solver_IsLessVar(self, left, right)
 840
 841    def IsLessCt(self, left, right, b):
 842        r""" b == (left < right)"""
 843        return _pywrapcp.Solver_IsLessCt(self, left, right, b)
 844
 845    def SumLessOrEqual(self, vars, cst):
 846        r""" Variation on arrays."""
 847        return _pywrapcp.Solver_SumLessOrEqual(self, vars, cst)
 848
 849    def SumGreaterOrEqual(self, vars, cst):
 850        return _pywrapcp.Solver_SumGreaterOrEqual(self, vars, cst)
 851
 852    def SumEquality(self, *args):
 853        return _pywrapcp.Solver_SumEquality(self, *args)
 854
 855    def ScalProdEquality(self, *args):
 856        return _pywrapcp.Solver_ScalProdEquality(self, *args)
 857
 858    def ScalProdGreaterOrEqual(self, *args):
 859        return _pywrapcp.Solver_ScalProdGreaterOrEqual(self, *args)
 860
 861    def ScalProdLessOrEqual(self, *args):
 862        return _pywrapcp.Solver_ScalProdLessOrEqual(self, *args)
 863
 864    def MinEquality(self, vars, min_var):
 865        return _pywrapcp.Solver_MinEquality(self, vars, min_var)
 866
 867    def MaxEquality(self, vars, max_var):
 868        return _pywrapcp.Solver_MaxEquality(self, vars, max_var)
 869
 870    def ElementEquality(self, *args):
 871        return _pywrapcp.Solver_ElementEquality(self, *args)
 872
 873    def AbsEquality(self, var, abs_var):
 874        r""" Creates the constraint abs(var) == abs_var."""
 875        return _pywrapcp.Solver_AbsEquality(self, var, abs_var)
 876
 877    def IndexOfConstraint(self, vars, index, target):
 878        r"""
 879        This constraint is a special case of the element constraint with
 880        an array of integer variables, where the variables are all
 881        different and the index variable is constrained such that
 882        vars[index] == target.
 883        """
 884        return _pywrapcp.Solver_IndexOfConstraint(self, vars, index, target)
 885
 886    def ConstraintInitialPropagateCallback(self, ct):
 887        r"""
 888        This method is a specialized case of the MakeConstraintDemon
 889        method to call the InitiatePropagate of the constraint 'ct'.
 890        """
 891        return _pywrapcp.Solver_ConstraintInitialPropagateCallback(self, ct)
 892
 893    def DelayedConstraintInitialPropagateCallback(self, ct):
 894        r"""
 895        This method is a specialized case of the MakeConstraintDemon
 896        method to call the InitiatePropagate of the constraint 'ct' with
 897        low priority.
 898        """
 899        return _pywrapcp.Solver_DelayedConstraintInitialPropagateCallback(self, ct)
 900
 901    def ClosureDemon(self, closure):
 902        r""" Creates a demon from a closure."""
 903        return _pywrapcp.Solver_ClosureDemon(self, closure)
 904
 905    def BetweenCt(self, expr, l, u):
 906        r""" (l <= expr <= u)"""
 907        return _pywrapcp.Solver_BetweenCt(self, expr, l, u)
 908
 909    def IsBetweenCt(self, expr, l, u, b):
 910        r""" b == (l <= expr <= u)"""
 911        return _pywrapcp.Solver_IsBetweenCt(self, expr, l, u, b)
 912
 913    def IsBetweenVar(self, v, l, u):
 914        return _pywrapcp.Solver_IsBetweenVar(self, v, l, u)
 915
 916    def MemberCt(self, *args):
 917        return _pywrapcp.Solver_MemberCt(self, *args)
 918
 919    def NotMemberCt(self, *args):
 920        r"""
 921        *Overload 1:*
 922        expr not in set.
 923
 924        |
 925
 926        *Overload 2:*
 927        expr should not be in the list of forbidden intervals [start[i]..end[i]].
 928
 929        |
 930
 931        *Overload 3:*
 932        expr should not be in the list of forbidden intervals [start[i]..end[i]].
 933        """
 934        return _pywrapcp.Solver_NotMemberCt(self, *args)
 935
 936    def IsMemberCt(self, *args):
 937        return _pywrapcp.Solver_IsMemberCt(self, *args)
 938
 939    def IsMemberVar(self, *args):
 940        return _pywrapcp.Solver_IsMemberVar(self, *args)
 941
 942    def Count(self, *args):
 943        r"""
 944        *Overload 1:*
 945        |{i | vars[i] == value}| == max_count
 946
 947        |
 948
 949        *Overload 2:*
 950        |{i | vars[i] == value}| == max_count
 951        """
 952        return _pywrapcp.Solver_Count(self, *args)
 953
 954    def Distribute(self, *args):
 955        r"""
 956        *Overload 1:*
 957        Aggregated version of count:  |{i | v[i] == values[j]}| == cards[j]
 958
 959        |
 960
 961        *Overload 2:*
 962        Aggregated version of count:  |{i | v[i] == values[j]}| == cards[j]
 963
 964        |
 965
 966        *Overload 3:*
 967        Aggregated version of count:  |{i | v[i] == j}| == cards[j]
 968
 969        |
 970
 971        *Overload 4:*
 972        Aggregated version of count with bounded cardinalities:
 973        forall j in 0 .. card_size - 1: card_min <= |{i | v[i] == j}| <= card_max
 974
 975        |
 976
 977        *Overload 5:*
 978        Aggregated version of count with bounded cardinalities:
 979        forall j in 0 .. card_size - 1:
 980           card_min[j] <= |{i | v[i] == j}| <= card_max[j]
 981
 982        |
 983
 984        *Overload 6:*
 985        Aggregated version of count with bounded cardinalities:
 986        forall j in 0 .. card_size - 1:
 987           card_min[j] <= |{i | v[i] == j}| <= card_max[j]
 988
 989        |
 990
 991        *Overload 7:*
 992        Aggregated version of count with bounded cardinalities:
 993        forall j in 0 .. card_size - 1:
 994           card_min[j] <= |{i | v[i] == values[j]}| <= card_max[j]
 995
 996        |
 997
 998        *Overload 8:*
 999        Aggregated version of count with bounded cardinalities:
1000        forall j in 0 .. card_size - 1:
1001           card_min[j] <= |{i | v[i] == values[j]}| <= card_max[j]
1002        """
1003        return _pywrapcp.Solver_Distribute(self, *args)
1004
1005    def Deviation(self, vars, deviation_var, total_sum):
1006        r"""
1007        Deviation constraint:
1008        sum_i |n * vars[i] - total_sum| <= deviation_var and
1009        sum_i vars[i] == total_sum
1010        n = #vars
1011        """
1012        return _pywrapcp.Solver_Deviation(self, vars, deviation_var, total_sum)
1013
1014    def AllDifferent(self, *args):
1015        r"""
1016        *Overload 1:*
1017        All variables are pairwise different. This corresponds to the
1018        stronger version of the propagation algorithm.
1019
1020        |
1021
1022        *Overload 2:*
1023        All variables are pairwise different.  If 'stronger_propagation'
1024        is true, stronger, and potentially slower propagation will
1025        occur. This API will be deprecated in the future.
1026        """
1027        return _pywrapcp.Solver_AllDifferent(self, *args)
1028
1029    def AllDifferentExcept(self, vars, escape_value):
1030        r"""
1031        All variables are pairwise different, unless they are assigned to
1032        the escape value.
1033        """
1034        return _pywrapcp.Solver_AllDifferentExcept(self, vars, escape_value)
1035
1036    def SortingConstraint(self, vars, sorted):
1037        r"""
1038        Creates a constraint binding the arrays of variables "vars" and
1039        "sorted_vars": sorted_vars[0] must be equal to the minimum of all
1040        variables in vars, and so on: the value of sorted_vars[i] must be
1041        equal to the i-th value of variables invars.
1042
1043        This constraint propagates in both directions: from "vars" to
1044        "sorted_vars" and vice-versa.
1045
1046        Behind the scenes, this constraint maintains that:
1047          - sorted is always increasing.
1048          - whatever the values of vars, there exists a permutation that
1049            injects its values into the sorted variables.
1050
1051        For more info, please have a look at:
1052          https://mpi-inf.mpg.de/~mehlhorn/ftp/Mehlhorn-Thiel.pdf
1053        """
1054        return _pywrapcp.Solver_SortingConstraint(self, vars, sorted)
1055
1056    def LexicalLess(self, left, right):
1057        r"""
1058        Creates a constraint that enforces that left is lexicographically less
1059        than right.
1060        """
1061        return _pywrapcp.Solver_LexicalLess(self, left, right)
1062
1063    def LexicalLessOrEqual(self, left, right):
1064        r"""
1065        Creates a constraint that enforces that left is lexicographically less
1066        than or equal to right.
1067        """
1068        return _pywrapcp.Solver_LexicalLessOrEqual(self, left, right)
1069
1070    def InversePermutationConstraint(self, left, right):
1071        r"""
1072        Creates a constraint that enforces that 'left' and 'right' both
1073        represent permutations of [0..left.size()-1], and that 'right' is
1074        the inverse permutation of 'left', i.e. for all i in
1075        [0..left.size()-1], right[left[i]] = i.
1076        """
1077        return _pywrapcp.Solver_InversePermutationConstraint(self, left, right)
1078
1079    def NullIntersect(self, first_vars, second_vars):
1080        r"""
1081        Creates a constraint that states that all variables in the first
1082        vector are different from all variables in the second
1083        group. Thus the set of values in the first vector does not
1084        intersect with the set of values in the second vector.
1085        """
1086        return _pywrapcp.Solver_NullIntersect(self, first_vars, second_vars)
1087
1088    def NullIntersectExcept(self, first_vars, second_vars, escape_value):
1089        r"""
1090        Creates a constraint that states that all variables in the first
1091        vector are different from all variables from the second group,
1092        unless they are assigned to the escape value. Thus the set of
1093        values in the first vector minus the escape value does not
1094        intersect with the set of values in the second vector.
1095        """
1096        return _pywrapcp.Solver_NullIntersectExcept(self, first_vars, second_vars, escape_value)
1097
1098    def Circuit(self, nexts):
1099        r""" Force the "nexts" variable to create a complete Hamiltonian path."""
1100        return _pywrapcp.Solver_Circuit(self, nexts)
1101
1102    def SubCircuit(self, nexts):
1103        r"""
1104        Force the "nexts" variable to create a complete Hamiltonian path
1105        for those that do not loop upon themselves.
1106        """
1107        return _pywrapcp.Solver_SubCircuit(self, nexts)
1108
1109    def DelayedPathCumul(self, nexts, active, cumuls, transits):
1110        r"""
1111        Delayed version of the same constraint: propagation on the nexts variables
1112        is delayed until all constraints have propagated.
1113        """
1114        return _pywrapcp.Solver_DelayedPathCumul(self, nexts, active, cumuls, transits)
1115
1116    def PathCumul(self, *args):
1117        r"""
1118        *Overload 1:*
1119        Creates a constraint which accumulates values along a path such that:
1120        cumuls[next[i]] = cumuls[i] + transits[i].
1121        Active variables indicate if the corresponding next variable is active;
1122        this could be useful to model unperformed nodes in a routing problem.
1123
1124        |
1125
1126        *Overload 2:*
1127        Creates a constraint which accumulates values along a path such that:
1128        cumuls[next[i]] = cumuls[i] + transit_evaluator(i, next[i]).
1129        Active variables indicate if the corresponding next variable is active;
1130        this could be useful to model unperformed nodes in a routing problem.
1131        Ownership of transit_evaluator is taken and it must be a repeatable
1132        callback.
1133
1134        |
1135
1136        *Overload 3:*
1137        Creates a constraint which accumulates values along a path such that:
1138        cumuls[next[i]] = cumuls[i] + transit_evaluator(i, next[i]) + slacks[i].
1139        Active variables indicate if the corresponding next variable is active;
1140        this could be useful to model unperformed nodes in a routing problem.
1141        Ownership of transit_evaluator is taken and it must be a repeatable
1142        callback.
1143        """
1144        return _pywrapcp.Solver_PathCumul(self, *args)
1145
1146    def AllowedAssignments(self, *args):
1147        r"""
1148        *Overload 1:*
1149        This method creates a constraint where the graph of the relation
1150        between the variables is given in extension. There are 'arity'
1151        variables involved in the relation and the graph is given by a
1152        integer tuple set.
1153
1154        |
1155
1156        *Overload 2:*
1157        Compatibility layer for Python API.
1158        """
1159        return _pywrapcp.Solver_AllowedAssignments(self, *args)
1160
1161    def TransitionConstraint(self, *args):
1162        return _pywrapcp.Solver_TransitionConstraint(self, *args)
1163
1164    def NonOverlappingBoxesConstraint(self, *args):
1165        return _pywrapcp.Solver_NonOverlappingBoxesConstraint(self, *args)
1166
1167    def Pack(self, vars, number_of_bins):
1168        r"""
1169        This constraint packs all variables onto 'number_of_bins'
1170        variables.  For any given variable, a value of 'number_of_bins'
1171        indicates that the variable is not assigned to any bin.
1172        Dimensions, i.e., cumulative constraints on this packing, can be
1173        added directly from the pack class.
1174        """
1175        return _pywrapcp.Solver_Pack(self, vars, number_of_bins)
1176
1177    def FixedDurationIntervalVar(self, *args):
1178        r"""
1179        *Overload 1:*
1180        Creates an interval var with a fixed duration. The duration must
1181        be greater than 0. If optional is true, then the interval can be
1182        performed or unperformed. If optional is false, then the interval
1183        is always performed.
1184
1185        |
1186
1187        *Overload 2:*
1188        Creates a performed interval var with a fixed duration. The duration must
1189        be greater than 0.
1190
1191        |
1192
1193        *Overload 3:*
1194        Creates an interval var with a fixed duration, and performed_variable.
1195        The duration must be greater than 0.
1196        """
1197        return _pywrapcp.Solver_FixedDurationIntervalVar(self, *args)
1198
1199    def FixedInterval(self, start, duration, name):
1200        r""" Creates a fixed and performed interval."""
1201        return _pywrapcp.Solver_FixedInterval(self, start, duration, name)
1202
1203    def IntervalVar(self, start_min, start_max, duration_min, duration_max, end_min, end_max, optional, name):
1204        r"""
1205        Creates an interval var by specifying the bounds on start,
1206        duration, and end.
1207        """
1208        return _pywrapcp.Solver_IntervalVar(self, start_min, start_max, duration_min, duration_max, end_min, end_max, optional, name)
1209
1210    def MirrorInterval(self, interval_var):
1211        r"""
1212        Creates an interval var that is the mirror image of the given one, that
1213        is, the interval var obtained by reversing the axis.
1214        """
1215        return _pywrapcp.Solver_MirrorInterval(self, interval_var)
1216
1217    def FixedDurationStartSyncedOnStartIntervalVar(self, interval_var, duration, offset):
1218        r"""
1219        Creates an interval var with a fixed duration whose start is
1220        synchronized with the start of another interval, with a given
1221        offset. The performed status is also in sync with the performed
1222        status of the given interval variable.
1223        """
1224        return _pywrapcp.Solver_FixedDurationStartSyncedOnStartIntervalVar(self, interval_var, duration, offset)
1225
1226    def FixedDurationStartSyncedOnEndIntervalVar(self, interval_var, duration, offset):
1227        r"""
1228        Creates an interval var with a fixed duration whose start is
1229        synchronized with the end of another interval, with a given
1230        offset. The performed status is also in sync with the performed
1231        status of the given interval variable.
1232        """
1233        return _pywrapcp.Solver_FixedDurationStartSyncedOnEndIntervalVar(self, interval_var, duration, offset)
1234
1235    def FixedDurationEndSyncedOnStartIntervalVar(self, interval_var, duration, offset):
1236        r"""
1237        Creates an interval var with a fixed duration whose end is
1238        synchronized with the start of another interval, with a given
1239        offset. The performed status is also in sync with the performed
1240        status of the given interval variable.
1241        """
1242        return _pywrapcp.Solver_FixedDurationEndSyncedOnStartIntervalVar(self, interval_var, duration, offset)
1243
1244    def FixedDurationEndSyncedOnEndIntervalVar(self, interval_var, duration, offset):
1245        r"""
1246        Creates an interval var with a fixed duration whose end is
1247        synchronized with the end of another interval, with a given
1248        offset. The performed status is also in sync with the performed
1249        status of the given interval variable.
1250        """
1251        return _pywrapcp.Solver_FixedDurationEndSyncedOnEndIntervalVar(self, interval_var, duration, offset)
1252
1253    def IntervalRelaxedMin(self, interval_var):
1254        r"""
1255         Creates and returns an interval variable that wraps around the given one,
1256         relaxing the min start and end. Relaxing means making unbounded when
1257         optional. If the variable is non-optional, this method returns
1258         interval_var.
1259
1260         More precisely, such an interval variable behaves as follows:
1261        When the underlying must be performed, the returned interval variable
1262             behaves exactly as the underlying;
1263        When the underlying may or may not be performed, the returned interval
1264             variable behaves like the underlying, except that it is unbounded on
1265             the min side;
1266        When the underlying cannot be performed, the returned interval variable
1267             is of duration 0 and must be performed in an interval unbounded on
1268             both sides.
1269
1270         This is very useful to implement propagators that may only modify
1271         the start max or end max.
1272        """
1273        return _pywrapcp.Solver_IntervalRelaxedMin(self, interval_var)
1274
1275    def IntervalRelaxedMax(self, interval_var):
1276        r"""
1277         Creates and returns an interval variable that wraps around the given one,
1278         relaxing the max start and end. Relaxing means making unbounded when
1279         optional. If the variable is non optional, this method returns
1280         interval_var.
1281
1282         More precisely, such an interval variable behaves as follows:
1283        When the underlying must be performed, the returned interval variable
1284             behaves exactly as the underlying;
1285        When the underlying may or may not be performed, the returned interval
1286             variable behaves like the underlying, except that it is unbounded on
1287             the max side;
1288        When the underlying cannot be performed, the returned interval variable
1289             is of duration 0 and must be performed in an interval unbounded on
1290             both sides.
1291
1292         This is very useful for implementing propagators that may only modify
1293         the start min or end min.
1294        """
1295        return _pywrapcp.Solver_IntervalRelaxedMax(self, interval_var)
1296
1297    def TemporalDisjunction(self, *args):
1298        r"""
1299        *Overload 1:*
1300        This constraint implements a temporal disjunction between two
1301        interval vars t1 and t2. 'alt' indicates which alternative was
1302        chosen (alt == 0 is equivalent to t1 before t2).
1303
1304        |
1305
1306        *Overload 2:*
1307        This constraint implements a temporal disjunction between two
1308        interval vars.
1309        """
1310        return _pywrapcp.Solver_TemporalDisjunction(self, *args)
1311
1312    def DisjunctiveConstraint(self, intervals, name):
1313        r"""
1314        This constraint forces all interval vars into an non-overlapping
1315        sequence. Intervals with zero duration can be scheduled anywhere.
1316        """
1317        return _pywrapcp.Solver_DisjunctiveConstraint(self, intervals, name)
1318
1319    def Cumulative(self, *args):
1320        r"""
1321        *Overload 1:*
1322        This constraint forces that, for any integer t, the sum of the demands
1323        corresponding to an interval containing t does not exceed the given
1324        capacity.
1325
1326        Intervals and demands should be vectors of equal size.
1327
1328        Demands should only contain non-negative values. Zero values are
1329        supported, and the corresponding intervals are filtered out, as they
1330        neither impact nor are impacted by this constraint.
1331
1332        |
1333
1334        *Overload 2:*
1335        This constraint forces that, for any integer t, the sum of the demands
1336        corresponding to an interval containing t does not exceed the given
1337        capacity.
1338
1339        Intervals and demands should be vectors of equal size.
1340
1341        Demands should only contain non-negative values. Zero values are
1342        supported, and the corresponding intervals are filtered out, as they
1343        neither impact nor are impacted by this constraint.
1344
1345        |
1346
1347        *Overload 3:*
1348        This constraint forces that, for any integer t, the sum of the demands
1349        corresponding to an interval containing t does not exceed the given
1350        capacity.
1351
1352        Intervals and demands should be vectors of equal size.
1353
1354        Demands should only contain non-negative values. Zero values are
1355        supported, and the corresponding intervals are filtered out, as they
1356        neither impact nor are impacted by this constraint.
1357
1358        |
1359
1360        *Overload 4:*
1361        This constraint enforces that, for any integer t, the sum of the demands
1362        corresponding to an interval containing t does not exceed the given
1363        capacity.
1364
1365        Intervals and demands should be vectors of equal size.
1366
1367        Demands should only contain non-negative values. Zero values are
1368        supported, and the corresponding intervals are filtered out, as they
1369        neither impact nor are impacted by this constraint.
1370
1371        |
1372
1373        *Overload 5:*
1374        This constraint enforces that, for any integer t, the sum of demands
1375        corresponding to an interval containing t does not exceed the given
1376        capacity.
1377
1378        Intervals and demands should be vectors of equal size.
1379
1380        Demands should be positive.
1381
1382        |
1383
1384        *Overload 6:*
1385        This constraint enforces that, for any integer t, the sum of demands
1386        corresponding to an interval containing t does not exceed the given
1387        capacity.
1388
1389        Intervals and demands should be vectors of equal size.
1390
1391        Demands should be positive.
1392        """
1393        return _pywrapcp.Solver_Cumulative(self, *args)
1394
1395    def Cover(self, vars, target_var):
1396        r"""
1397        This constraint states that the target_var is the convex hull of
1398        the intervals. If none of the interval variables is performed,
1399        then the target var is unperformed too. Also, if the target
1400        variable is unperformed, then all the intervals variables are
1401        unperformed too.
1402        """
1403        return _pywrapcp.Solver_Cover(self, vars, target_var)
1404
1405    def Assignment(self, *args):
1406        r"""
1407        *Overload 1:*
1408        This method creates an empty assignment.
1409
1410        |
1411
1412        *Overload 2:*
1413        This method creates an assignment which is a copy of 'a'.
1414        """
1415        return _pywrapcp.Solver_Assignment(self, *args)
1416
1417    def FirstSolutionCollector(self, *args):
1418        r"""
1419        *Overload 1:*
1420        Collect the first solution of the search.
1421
1422        |
1423
1424        *Overload 2:*
1425        Collect the first solution of the search. The variables will need to
1426        be added later.
1427        """
1428        return _pywrapcp.Solver_FirstSolutionCollector(self, *args)
1429
1430    def LastSolutionCollector(self, *args):
1431        r"""
1432        *Overload 1:*
1433        Collect the last solution of the search.
1434
1435        |
1436
1437        *Overload 2:*
1438        Collect the last solution of the search. The variables will need to
1439        be added later.
1440        """
1441        return _pywrapcp.Solver_LastSolutionCollector(self, *args)
1442
1443    def BestValueSolutionCollector(self, *args):
1444        r"""
1445        *Overload 1:*
1446        Collect the solution corresponding to the optimal value of the objective
1447        of 'assignment'; if 'assignment' does not have an objective no solution is
1448        collected. This collector only collects one solution corresponding to the
1449        best objective value (the first one found).
1450
1451        |
1452
1453        *Overload 2:*
1454        Collect the solution corresponding to the optimal value of the
1455        objective of 'assignment'; if 'assignment' does not have an objective no
1456        solution is collected. This collector only collects one solution
1457        corresponding to the best objective value (the first one
1458        found). The variables will need to be added later.
1459        """
1460        return _pywrapcp.Solver_BestValueSolutionCollector(self, *args)
1461
1462    def AllSolutionCollector(self, *args):
1463        r"""
1464        *Overload 1:*
1465        Collect all solutions of the search.
1466
1467        |
1468
1469        *Overload 2:*
1470        Collect all solutions of the search. The variables will need to
1471        be added later.
1472        """
1473        return _pywrapcp.Solver_AllSolutionCollector(self, *args)
1474
1475    def Minimize(self, v, step):
1476        r""" Creates a minimization objective."""
1477        return _pywrapcp.Solver_Minimize(self, v, step)
1478
1479    def Maximize(self, v, step):
1480        r""" Creates a maximization objective."""
1481        return _pywrapcp.Solver_Maximize(self, v, step)
1482
1483    def Optimize(self, maximize, v, step):
1484        r""" Creates a objective with a given sense (true = maximization)."""
1485        return _pywrapcp.Solver_Optimize(self, maximize, v, step)
1486
1487    def WeightedMinimize(self, *args):
1488        r"""
1489        *Overload 1:*
1490        Creates a minimization weighted objective. The actual objective is
1491        scalar_prod(sub_objectives, weights).
1492
1493        |
1494
1495        *Overload 2:*
1496        Creates a minimization weighted objective. The actual objective is
1497        scalar_prod(sub_objectives, weights).
1498        """
1499        return _pywrapcp.Solver_WeightedMinimize(self, *args)
1500
1501    def WeightedMaximize(self, *args):
1502        r"""
1503        *Overload 1:*
1504        Creates a maximization weigthed objective.
1505
1506        |
1507
1508        *Overload 2:*
1509        Creates a maximization weigthed objective.
1510        """
1511        return _pywrapcp.Solver_WeightedMaximize(self, *args)
1512
1513    def WeightedOptimize(self, *args):
1514        r"""
1515        *Overload 1:*
1516        Creates a weighted objective with a given sense (true = maximization).
1517
1518        |
1519
1520        *Overload 2:*
1521        Creates a weighted objective with a given sense (true = maximization).
1522        """
1523        return _pywrapcp.Solver_WeightedOptimize(self, *args)
1524
1525    def TabuSearch(self, maximize, v, step, vars, keep_tenure, forbid_tenure, tabu_factor):
1526        r"""
1527        MetaHeuristics which try to get the search out of local optima.
1528        Creates a Tabu Search monitor.
1529        In the context of local search the behavior is similar to MakeOptimize(),
1530        creating an objective in a given sense. The behavior differs once a local
1531        optimum is reached: thereafter solutions which degrade the value of the
1532        objective are allowed if they are not "tabu". A solution is "tabu" if it
1533        doesn't respect the following rules:
1534        - improving the best solution found so far
1535        - variables in the "keep" list must keep their value, variables in the
1536        "forbid" list must not take the value they have in the list.
1537        Variables with new values enter the tabu lists after each new solution
1538        found and leave the lists after a given number of iterations (called
1539        tenure). Only the variables passed to the method can enter the lists.
1540        The tabu criterion is softened by the tabu factor which gives the number
1541        of "tabu" violations which is tolerated; a factor of 1 means no violations
1542        allowed; a factor of 0 means all violations are allowed.
1543        """
1544        return _pywrapcp.Solver_TabuSearch(self, maximize, v, step, vars, keep_tenure, forbid_tenure, tabu_factor)
1545
1546    def SimulatedAnnealing(self, maximize, v, step, initial_temperature):
1547        r""" Creates a Simulated Annealing monitor."""
1548        return _pywrapcp.Solver_SimulatedAnnealing(self, maximize, v, step, initial_temperature)
1549
1550    def LubyRestart(self, scale_factor):
1551        r"""
1552        This search monitor will restart the search periodically.
1553        At the iteration n, it will restart after scale_factor * Luby(n) failures
1554        where Luby is the Luby Strategy (i.e. 1 1 2 1 1 2 4 1 1 2 1 1 2 4 8...).
1555        """
1556        return _pywrapcp.Solver_LubyRestart(self, scale_factor)
1557
1558    def ConstantRestart(self, frequency):
1559        r"""
1560        This search monitor will restart the search periodically after 'frequency'
1561        failures.
1562        """
1563        return _pywrapcp.Solver_ConstantRestart(self, frequency)
1564
1565    def TimeLimit(self, *args):
1566        return _pywrapcp.Solver_TimeLimit(self, *args)
1567
1568    def BranchesLimit(self, branches):
1569        r"""
1570        Creates a search limit that constrains the number of branches
1571        explored in the search tree.
1572        """
1573        return _pywrapcp.Solver_BranchesLimit(self, branches)
1574
1575    def FailuresLimit(self, failures):
1576        r"""
1577        Creates a search limit that constrains the number of failures
1578        that can happen when exploring the search tree.
1579        """
1580        return _pywrapcp.Solver_FailuresLimit(self, failures)
1581
1582    def SolutionsLimit(self, solutions):
1583        r"""
1584        Creates a search limit that constrains the number of solutions found
1585        during the search.
1586        """
1587        return _pywrapcp.Solver_SolutionsLimit(self, solutions)
1588
1589    def Limit(self, *args):
1590        r"""
1591        *Overload 1:*
1592        Limits the search with the 'time', 'branches', 'failures' and
1593        'solutions' limits. 'smart_time_check' reduces the calls to the wall
1594
1595        |
1596
1597        *Overload 2:*
1598        Creates a search limit from its protobuf description
1599
1600        |
1601
1602        *Overload 3:*
1603        Creates a search limit that is reached when either of the underlying limit
1604        is reached. That is, the returned limit is more stringent than both
1605        argument limits.
1606        """
1607        return _pywrapcp.Solver_Limit(self, *args)
1608
1609    def CustomLimit(self, limiter):
1610        r"""
1611        Callback-based search limit. Search stops when limiter returns true; if
1612        this happens at a leaf the corresponding solution will be rejected.
1613        """
1614        return _pywrapcp.Solver_CustomLimit(self, limiter)
1615
1616    def SearchLog(self, *args):
1617        return _pywrapcp.Solver_SearchLog(self, *args)
1618
1619    def SearchTrace(self, prefix):
1620        r"""
1621        Creates a search monitor that will trace precisely the behavior of the
1622        search. Use this only for low level debugging.
1623        """
1624        return _pywrapcp.Solver_SearchTrace(self, prefix)
1625
1626    def PrintModelVisitor(self):
1627        r""" Prints the model."""
1628        return _pywrapcp.Solver_PrintModelVisitor(self)
1629
1630    def StatisticsModelVisitor(self):
1631        r""" Displays some nice statistics on the model."""
1632        return _pywrapcp.Solver_StatisticsModelVisitor(self)
1633
1634    def AssignVariableValue(self, var, val):
1635        r""" Decisions."""
1636        return _pywrapcp.Solver_AssignVariableValue(self, var, val)
1637
1638    def VariableLessOrEqualValue(self, var, value):
1639        return _pywrapcp.Solver_VariableLessOrEqualValue(self, var, value)
1640
1641    def VariableGreaterOrEqualValue(self, var, value):
1642        return _pywrapcp.Solver_VariableGreaterOrEqualValue(self, var, value)
1643
1644    def SplitVariableDomain(self, var, val, start_with_lower_half):
1645        return _pywrapcp.Solver_SplitVariableDomain(self, var, val, start_with_lower_half)
1646
1647    def AssignVariableValueOrFail(self, var, value):
1648        return _pywrapcp.Solver_AssignVariableValueOrFail(self, var, value)
1649
1650    def AssignVariablesValues(self, vars, values):
1651        return _pywrapcp.Solver_AssignVariablesValues(self, vars, values)
1652
1653    def FailDecision(self):
1654        return _pywrapcp.Solver_FailDecision(self)
1655
1656    def Decision(self, apply, refute):
1657        return _pywrapcp.Solver_Decision(self, apply, refute)
1658
1659    def Compose(self, dbs):
1660        return _pywrapcp.Solver_Compose(self, dbs)
1661
1662    def Try(self, dbs):
1663        return _pywrapcp.Solver_Try(self, dbs)
1664
1665    def DefaultPhase(self, *args):
1666        return _pywrapcp.Solver_DefaultPhase(self, *args)
1667
1668    def ScheduleOrPostpone(self, var, est, marker):
1669        r"""
1670        Returns a decision that tries to schedule a task at a given time.
1671        On the Apply branch, it will set that interval var as performed and set
1672        its start to 'est'. On the Refute branch, it will just update the
1673        'marker' to 'est' + 1. This decision is used in the
1674        INTERVAL_SET_TIMES_FORWARD strategy.
1675        """
1676        return _pywrapcp.Solver_ScheduleOrPostpone(self, var, est, marker)
1677
1678    def ScheduleOrExpedite(self, var, est, marker):
1679        r"""
1680        Returns a decision that tries to schedule a task at a given time.
1681        On the Apply branch, it will set that interval var as performed and set
1682        its end to 'est'. On the Refute branch, it will just update the
1683        'marker' to 'est' - 1. This decision is used in the
1684        INTERVAL_SET_TIMES_BACKWARD strategy.
1685        """
1686        return _pywrapcp.Solver_ScheduleOrExpedite(self, var, est, marker)
1687
1688    def RankFirstInterval(self, sequence, index):
1689        r"""
1690        Returns a decision that tries to rank first the ith interval var
1691        in the sequence variable.
1692        """
1693        return _pywrapcp.Solver_RankFirstInterval(self, sequence, index)
1694
1695    def RankLastInterval(self, sequence, index):
1696        r"""
1697        Returns a decision that tries to rank last the ith interval var
1698        in the sequence variable.
1699        """
1700        return _pywrapcp.Solver_RankLastInterval(self, sequence, index)
1701
1702    def Phase(self, *args):
1703        return _pywrapcp.Solver_Phase(self, *args)
1704
1705    def DecisionBuilderFromAssignment(self, assignment, db, vars):
1706        r"""
1707        Returns a decision builder for which the left-most leaf corresponds
1708        to assignment, the rest of the tree being explored using 'db'.
1709        """
1710        return _pywrapcp.Solver_DecisionBuilderFromAssignment(self, assignment, db, vars)
1711
1712    def ConstraintAdder(self, ct):
1713        r"""
1714        Returns a decision builder that will add the given constraint to
1715        the model.
1716        """
1717        return _pywrapcp.Solver_ConstraintAdder(self, ct)
1718
1719    def SolveOnce(self, db, monitors):
1720        return _pywrapcp.Solver_SolveOnce(self, db, monitors)
1721
1722    def NestedOptimize(self, *args):
1723        return _pywrapcp.Solver_NestedOptimize(self, *args)
1724
1725    def RestoreAssignment(self, assignment):
1726        r"""
1727        Returns a DecisionBuilder which restores an Assignment
1728        (calls void Assignment::Restore())
1729        """
1730        return _pywrapcp.Solver_RestoreAssignment(self, assignment)
1731
1732    def StoreAssignment(self, assignment):
1733        r"""
1734        Returns a DecisionBuilder which stores an Assignment
1735        (calls void Assignment::Store())
1736        """
1737        return _pywrapcp.Solver_StoreAssignment(self, assignment)
1738
1739    def Operator(self, *args):
1740        return _pywrapcp.Solver_Operator(self, *args)
1741
1742    def RandomLnsOperator(self, *args):
1743        return _pywrapcp.Solver_RandomLnsOperator(self, *args)
1744
1745    def MoveTowardTargetOperator(self, *args):
1746        r"""
1747        *Overload 1:*
1748        Creates a local search operator that tries to move the assignment of some
1749        variables toward a target. The target is given as an Assignment. This
1750        operator generates neighbors in which the only difference compared to the
1751        current state is that one variable that belongs to the target assignment
1752        is set to its target value.
1753
1754        |
1755
1756        *Overload 2:*
1757        Creates a local search operator that tries to move the assignment of some
1758        variables toward a target. The target is given either as two vectors: a
1759        vector of variables and a vector of associated target values. The two
1760        vectors should be of the same length. This operator generates neighbors in
1761        which the only difference compared to the current state is that one
1762        variable that belongs to the given vector is set to its target value.
1763        """
1764        return _pywrapcp.Solver_MoveTowardTargetOperator(self, *args)
1765
1766    def ConcatenateOperators(self, *args):
1767        return _pywrapcp.Solver_ConcatenateOperators(self, *args)
1768
1769    def RandomConcatenateOperators(self, *args):
1770        r"""
1771        *Overload 1:*
1772        Randomized version of local search concatenator; calls a random operator
1773        at each call to MakeNextNeighbor().
1774
1775        |
1776
1777        *Overload 2:*
1778        Randomized version of local search concatenator; calls a random operator
1779        at each call to MakeNextNeighbor(). The provided seed is used to
1780        initialize the random number generator.
1781        """
1782        return _pywrapcp.Solver_RandomConcatenateOperators(self, *args)
1783
1784    def NeighborhoodLimit(self, op, limit):
1785        r"""
1786        Creates a local search operator that wraps another local search
1787        operator and limits the number of neighbors explored (i.e., calls
1788        to MakeNextNeighbor from the current solution (between two calls
1789        to Start()). When this limit is reached, MakeNextNeighbor()
1790        returns false. The counter is cleared when Start() is called.
1791        """
1792        return _pywrapcp.Solver_NeighborhoodLimit(self, op, limit)
1793
1794    def LocalSearchPhase(self, *args):
1795        return _pywrapcp.Solver_LocalSearchPhase(self, *args)
1796
1797    def LocalSearchPhaseParameters(self, *args):
1798        return _pywrapcp.Solver_LocalSearchPhaseParameters(self, *args)
1799
1800    def SearchDepth(self):
1801        r"""
1802        Gets the search depth of the current active search. Returns -1 if
1803        there is no active search opened.
1804        """
1805        return _pywrapcp.Solver_SearchDepth(self)
1806
1807    def SearchLeftDepth(self):
1808        r"""
1809        Gets the search left depth of the current active search. Returns -1 if
1810        there is no active search opened.
1811        """
1812        return _pywrapcp.Solver_SearchLeftDepth(self)
1813
1814    def SolveDepth(self):
1815        r"""
1816        Gets the number of nested searches. It returns 0 outside search,
1817        1 during the top level search, 2 or more in case of nested searches.
1818        """
1819        return _pywrapcp.Solver_SolveDepth(self)
1820
1821    def Rand64(self, size):
1822        r""" Returns a random value between 0 and 'size' - 1;"""
1823        return _pywrapcp.Solver_Rand64(self, size)
1824
1825    def Rand32(self, size):
1826        r""" Returns a random value between 0 and 'size' - 1;"""
1827        return _pywrapcp.Solver_Rand32(self, size)
1828
1829    def ReSeed(self, seed):
1830        r""" Reseed the solver random generator."""
1831        return _pywrapcp.Solver_ReSeed(self, seed)
1832
1833    def LocalSearchProfile(self):
1834        r""" Returns local search profiling information in a human readable format."""
1835        return _pywrapcp.Solver_LocalSearchProfile(self)
1836
1837    def Constraints(self):
1838        r"""
1839        Counts the number of constraints that have been added
1840        to the solver before the search.
1841        """
1842        return _pywrapcp.Solver_Constraints(self)
1843
1844    def Accept(self, visitor):
1845        r""" Accepts the given model visitor."""
1846        return _pywrapcp.Solver_Accept(self, visitor)
1847
1848    def FinishCurrentSearch(self):
1849        r""" Tells the solver to kill or restart the current search."""
1850        return _pywrapcp.Solver_FinishCurrentSearch(self)
1851
1852    def RestartCurrentSearch(self):
1853        return _pywrapcp.Solver_RestartCurrentSearch(self)
1854
1855    def ShouldFail(self):
1856        r"""
1857        These methods are only useful for the SWIG wrappers, which need a way
1858        to externally cause the Solver to fail.
1859        """
1860        return _pywrapcp.Solver_ShouldFail(self)
1861
1862    def __str__(self):
1863        return _pywrapcp.Solver___str__(self)
1864
1865    def Add(self, ct):
1866      if isinstance(ct, PyConstraint):
1867        self.__python_constraints.append(ct)
1868      self.AddConstraint(ct)
1869
1870
1871    def TreeNoCycle(self, nexts, active, callback=0):
1872        return _pywrapcp.Solver_TreeNoCycle(self, nexts, active, callback)
1873
1874    def SearchLogWithCallback(self, period, callback):
1875        return _pywrapcp.Solver_SearchLogWithCallback(self, period, callback)
1876
1877    def ElementFunction(self, values, index):
1878        return _pywrapcp.Solver_ElementFunction(self, values, index)
1879
1880    def VarEvalValStrPhase(self, vars, var_evaluator, val_str):
1881        return _pywrapcp.Solver_VarEvalValStrPhase(self, vars, var_evaluator, val_str)
1882
1883    def VarStrValEvalPhase(self, vars, var_str, val_eval):
1884        return _pywrapcp.Solver_VarStrValEvalPhase(self, vars, var_str, val_eval)
1885
1886    def VarEvalValEvalPhase(self, vars, var_eval, val_eval):
1887        return _pywrapcp.Solver_VarEvalValEvalPhase(self, vars, var_eval, val_eval)
1888
1889    def VarStrValEvalTieBreakPhase(self, vars, var_str, val_eval, tie_breaker):
1890        return _pywrapcp.Solver_VarStrValEvalTieBreakPhase(self, vars, var_str, val_eval, tie_breaker)
1891
1892    def VarEvalValEvalTieBreakPhase(self, vars, var_eval, val_eval, tie_breaker):
1893        return _pywrapcp.Solver_VarEvalValEvalTieBreakPhase(self, vars, var_eval, val_eval, tie_breaker)
1894
1895    def EvalEvalStrPhase(self, vars, evaluator, str):
1896        return _pywrapcp.Solver_EvalEvalStrPhase(self, vars, evaluator, str)
1897
1898    def EvalEvalStrTieBreakPhase(self, vars, evaluator, tie_breaker, str):
1899        return _pywrapcp.Solver_EvalEvalStrTieBreakPhase(self, vars, evaluator, tie_breaker, str)
1900
1901    def GuidedLocalSearch(self, *args):
1902        return _pywrapcp.Solver_GuidedLocalSearch(self, *args)
1903
1904    def SumObjectiveFilter(self, vars, values, filter_enum):
1905        return _pywrapcp.Solver_SumObjectiveFilter(self, vars, values, filter_enum)
1906
1907# Register Solver in _pywrapcp:
1908_pywrapcp.Solver_swigregister(Solver)
1909class BaseObject(object):
1910    r"""
1911    A BaseObject is the root of all reversibly allocated objects.
1912    A DebugString method and the associated << operator are implemented
1913    as a convenience.
1914    """
1915
1916    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
1917
1918    def __init__(self):
1919        if self.__class__ == BaseObject:
1920            _self = None
1921        else:
1922            _self = self
1923        _pywrapcp.BaseObject_swiginit(self, _pywrapcp.new_BaseObject(_self, ))
1924    __swig_destroy__ = _pywrapcp.delete_BaseObject
1925
1926    def DebugString(self):
1927        return _pywrapcp.BaseObject_DebugString(self)
1928
1929    def __str__(self):
1930        return _pywrapcp.BaseObject___str__(self)
1931
1932    def __repr__(self):
1933        return _pywrapcp.BaseObject___repr__(self)
1934    def __disown__(self):
1935        self.this.disown()
1936        _pywrapcp.disown_BaseObject(self)
1937        return weakref.proxy(self)
1938
1939# Register BaseObject in _pywrapcp:
1940_pywrapcp.BaseObject_swigregister(BaseObject)
1941class PropagationBaseObject(BaseObject):
1942    r"""
1943    NOLINT
1944    The PropagationBaseObject is a subclass of BaseObject that is also
1945    friend to the Solver class. It allows accessing methods useful when
1946    writing new constraints or new expressions.
1947    """
1948
1949    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
1950    __repr__ = _swig_repr
1951
1952    def __init__(self, s):
1953        if self.__class__ == PropagationBaseObject:
1954            _self = None
1955        else:
1956            _self = self
1957        _pywrapcp.PropagationBaseObject_swiginit(self, _pywrapcp.new_PropagationBaseObject(_self, s))
1958    __swig_destroy__ = _pywrapcp.delete_PropagationBaseObject
1959
1960    def DebugString(self):
1961        return _pywrapcp.PropagationBaseObject_DebugString(self)
1962
1963    def solver(self):
1964        return _pywrapcp.PropagationBaseObject_solver(self)
1965
1966    def Name(self):
1967        r""" Object naming."""
1968        return _pywrapcp.PropagationBaseObject_Name(self)
1969    def __disown__(self):
1970        self.this.disown()
1971        _pywrapcp.disown_PropagationBaseObject(self)
1972        return weakref.proxy(self)
1973
1974# Register PropagationBaseObject in _pywrapcp:
1975_pywrapcp.PropagationBaseObject_swigregister(PropagationBaseObject)
1976class Decision(BaseObject):
1977    r"""
1978    A Decision represents a choice point in the search tree. The two main
1979    methods are Apply() to go left, or Refute() to go right.
1980    """
1981
1982    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
1983
1984    def __init__(self):
1985        if self.__class__ == Decision:
1986            _self = None
1987        else:
1988            _self = self
1989        _pywrapcp.Decision_swiginit(self, _pywrapcp.new_Decision(_self, ))
1990    __swig_destroy__ = _pywrapcp.delete_Decision
1991
1992    def ApplyWrapper(self, s):
1993        r""" Apply will be called first when the decision is executed."""
1994        return _pywrapcp.Decision_ApplyWrapper(self, s)
1995
1996    def RefuteWrapper(self, s):
1997        r""" Refute will be called after a backtrack."""
1998        return _pywrapcp.Decision_RefuteWrapper(self, s)
1999
2000    def DebugString(self):
2001        return _pywrapcp.Decision_DebugString(self)
2002
2003    def __repr__(self):
2004        return _pywrapcp.Decision___repr__(self)
2005
2006    def __str__(self):
2007        return _pywrapcp.Decision___str__(self)
2008    def __disown__(self):
2009        self.this.disown()
2010        _pywrapcp.disown_Decision(self)
2011        return weakref.proxy(self)
2012
2013# Register Decision in _pywrapcp:
2014_pywrapcp.Decision_swigregister(Decision)
2015class DecisionBuilder(BaseObject):
2016    r"""
2017    A DecisionBuilder is responsible for creating the search tree. The
2018    important method is Next(), which returns the next decision to execute.
2019    """
2020
2021    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2022
2023    def __init__(self):
2024        if self.__class__ == DecisionBuilder:
2025            _self = None
2026        else:
2027            _self = self
2028        _pywrapcp.DecisionBuilder_swiginit(self, _pywrapcp.new_DecisionBuilder(_self, ))
2029    __swig_destroy__ = _pywrapcp.delete_DecisionBuilder
2030
2031    def NextWrapper(self, s):
2032        r"""
2033        This is the main method of the decision builder class. It must
2034        return a decision (an instance of the class Decision). If it
2035        returns nullptr, this means that the decision builder has finished
2036        its work.
2037        """
2038        return _pywrapcp.DecisionBuilder_NextWrapper(self, s)
2039
2040    def DebugString(self):
2041        return _pywrapcp.DecisionBuilder_DebugString(self)
2042
2043    def __repr__(self):
2044        return _pywrapcp.DecisionBuilder___repr__(self)
2045
2046    def __str__(self):
2047        return _pywrapcp.DecisionBuilder___str__(self)
2048    def __disown__(self):
2049        self.this.disown()
2050        _pywrapcp.disown_DecisionBuilder(self)
2051        return weakref.proxy(self)
2052
2053# Register DecisionBuilder in _pywrapcp:
2054_pywrapcp.DecisionBuilder_swigregister(DecisionBuilder)
2055class Demon(BaseObject):
2056    r"""
2057    A Demon is the base element of a propagation queue. It is the main
2058      object responsible for implementing the actual propagation
2059      of the constraint and pruning the inconsistent values in the domains
2060      of the variables. The main concept is that demons are listeners that are
2061      attached to the variables and listen to their modifications.
2062    There are two methods:
2063     - Run() is the actual method called when the demon is processed.
2064     - priority() returns its priority. Standard priorities are slow, normal
2065       or fast. "immediate" is reserved for variables and is treated separately.
2066    """
2067
2068    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2069    __repr__ = _swig_repr
2070
2071    def __init__(self):
2072        r"""
2073        This indicates the priority of a demon. Immediate demons are treated
2074        separately and corresponds to variables.
2075        """
2076        if self.__class__ == Demon:
2077            _self = None
2078        else:
2079            _self = self
2080        _pywrapcp.Demon_swiginit(self, _pywrapcp.new_Demon(_self, ))
2081    __swig_destroy__ = _pywrapcp.delete_Demon
2082
2083    def RunWrapper(self, s):
2084        r""" This is the main callback of the demon."""
2085        return _pywrapcp.Demon_RunWrapper(self, s)
2086
2087    def Priority(self):
2088        r"""
2089        This method returns the priority of the demon. Usually a demon is
2090        fast, slow or normal. Immediate demons are reserved for internal
2091        use to maintain variables.
2092        """
2093        return _pywrapcp.Demon_Priority(self)
2094
2095    def DebugString(self):
2096        return _pywrapcp.Demon_DebugString(self)
2097
2098    def Inhibit(self, s):
2099        r"""
2100        This method inhibits the demon in the search tree below the
2101        current position.
2102        """
2103        return _pywrapcp.Demon_Inhibit(self, s)
2104
2105    def Desinhibit(self, s):
2106        r""" This method un-inhibits the demon that was previously inhibited."""
2107        return _pywrapcp.Demon_Desinhibit(self, s)
2108    def __disown__(self):
2109        self.this.disown()
2110        _pywrapcp.disown_Demon(self)
2111        return weakref.proxy(self)
2112
2113# Register Demon in _pywrapcp:
2114_pywrapcp.Demon_swigregister(Demon)
2115class Constraint(PropagationBaseObject):
2116    r"""
2117    A constraint is the main modeling object. It provides two methods:
2118      - Post() is responsible for creating the demons and attaching them to
2119        immediate demons().
2120      - InitialPropagate() is called once just after Post and performs
2121        the initial propagation. The subsequent propagations will be performed
2122        by the demons Posted during the post() method.
2123    """
2124
2125    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2126
2127    def __init__(self, solver):
2128        if self.__class__ == Constraint:
2129            _self = None
2130        else:
2131            _self = self
2132        _pywrapcp.Constraint_swiginit(self, _pywrapcp.new_Constraint(_self, solver))
2133    __swig_destroy__ = _pywrapcp.delete_Constraint
2134
2135    def Post(self):
2136        r"""
2137        This method is called when the constraint is processed by the
2138        solver. Its main usage is to attach demons to variables.
2139        """
2140        return _pywrapcp.Constraint_Post(self)
2141
2142    def InitialPropagateWrapper(self):
2143        r"""
2144        This method performs the initial propagation of the
2145        constraint. It is called just after the post.
2146        """
2147        return _pywrapcp.Constraint_InitialPropagateWrapper(self)
2148
2149    def DebugString(self):
2150        return _pywrapcp.Constraint_DebugString(self)
2151
2152    def Var(self):
2153        r"""
2154        Creates a Boolean variable representing the status of the constraint
2155        (false = constraint is violated, true = constraint is satisfied). It
2156        returns nullptr if the constraint does not support this API.
2157        """
2158        return _pywrapcp.Constraint_Var(self)
2159
2160    def __repr__(self):
2161        return _pywrapcp.Constraint___repr__(self)
2162
2163    def __str__(self):
2164        return _pywrapcp.Constraint___str__(self)
2165
2166    def __add__(self, *args):
2167        return _pywrapcp.Constraint___add__(self, *args)
2168
2169    def __radd__(self, v):
2170        return _pywrapcp.Constraint___radd__(self, v)
2171
2172    def __sub__(self, *args):
2173        return _pywrapcp.Constraint___sub__(self, *args)
2174
2175    def __rsub__(self, v):
2176        return _pywrapcp.Constraint___rsub__(self, v)
2177
2178    def __mul__(self, *args):
2179        return _pywrapcp.Constraint___mul__(self, *args)
2180
2181    def __rmul__(self, v):
2182        return _pywrapcp.Constraint___rmul__(self, v)
2183
2184    def __floordiv__(self, v):
2185        return _pywrapcp.Constraint___floordiv__(self, v)
2186
2187    def __neg__(self):
2188        return _pywrapcp.Constraint___neg__(self)
2189
2190    def __abs__(self):
2191        return _pywrapcp.Constraint___abs__(self)
2192
2193    def Square(self):
2194        return _pywrapcp.Constraint_Square(self)
2195
2196    def __eq__(self, *args):
2197        return _pywrapcp.Constraint___eq__(self, *args)
2198
2199    def __ne__(self, *args):
2200        return _pywrapcp.Constraint___ne__(self, *args)
2201
2202    def __ge__(self, *args):
2203        return _pywrapcp.Constraint___ge__(self, *args)
2204
2205    def __gt__(self, *args):
2206        return _pywrapcp.Constraint___gt__(self, *args)
2207
2208    def __le__(self, *args):
2209        return _pywrapcp.Constraint___le__(self, *args)
2210
2211    def __lt__(self, *args):
2212        return _pywrapcp.Constraint___lt__(self, *args)
2213
2214    def MapTo(self, vars):
2215        return _pywrapcp.Constraint_MapTo(self, vars)
2216
2217    def IndexOf(self, *args):
2218        return _pywrapcp.Constraint_IndexOf(self, *args)
2219    def __disown__(self):
2220        self.this.disown()
2221        _pywrapcp.disown_Constraint(self)
2222        return weakref.proxy(self)
2223
2224# Register Constraint in _pywrapcp:
2225_pywrapcp.Constraint_swigregister(Constraint)
2226class SearchMonitor(BaseObject):
2227    r""" A search monitor is a simple set of callbacks to monitor all search events"""
2228
2229    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2230
2231    def __init__(self, s):
2232        if self.__class__ == SearchMonitor:
2233            _self = None
2234        else:
2235            _self = self
2236        _pywrapcp.SearchMonitor_swiginit(self, _pywrapcp.new_SearchMonitor(_self, s))
2237    __swig_destroy__ = _pywrapcp.delete_SearchMonitor
2238
2239    def EnterSearch(self):
2240        r""" Beginning of the search."""
2241        return _pywrapcp.SearchMonitor_EnterSearch(self)
2242
2243    def RestartSearch(self):
2244        r""" Restart the search."""
2245        return _pywrapcp.SearchMonitor_RestartSearch(self)
2246
2247    def ExitSearch(self):
2248        r""" End of the search."""
2249        return _pywrapcp.SearchMonitor_ExitSearch(self)
2250
2251    def BeginNextDecision(self, b):
2252        r""" Before calling DecisionBuilder::Next."""
2253        return _pywrapcp.SearchMonitor_BeginNextDecision(self, b)
2254
2255    def EndNextDecision(self, b, d):
2256        r""" After calling DecisionBuilder::Next, along with the returned decision."""
2257        return _pywrapcp.SearchMonitor_EndNextDecision(self, b, d)
2258
2259    def ApplyDecision(self, d):
2260        r""" Before applying the decision."""
2261        return _pywrapcp.SearchMonitor_ApplyDecision(self, d)
2262
2263    def RefuteDecision(self, d):
2264        r""" Before refuting the decision."""
2265        return _pywrapcp.SearchMonitor_RefuteDecision(self, d)
2266
2267    def AfterDecision(self, d, apply):
2268        r"""
2269        Just after refuting or applying the decision, apply is true after Apply.
2270        This is called only if the Apply() or Refute() methods have not failed.
2271        """
2272        return _pywrapcp.SearchMonitor_AfterDecision(self, d, apply)
2273
2274    def BeginFail(self):
2275        r""" Just when the failure occurs."""
2276        return _pywrapcp.SearchMonitor_BeginFail(self)
2277
2278    def EndFail(self):
2279        r""" After completing the backtrack."""
2280        return _pywrapcp.SearchMonitor_EndFail(self)
2281
2282    def BeginInitialPropagation(self):
2283        r""" Before the initial propagation."""
2284        return _pywrapcp.SearchMonitor_BeginInitialPropagation(self)
2285
2286    def EndInitialPropagation(self):
2287        r""" After the initial propagation."""
2288        return _pywrapcp.SearchMonitor_EndInitialPropagation(self)
2289
2290    def AcceptSolution(self):
2291        r"""
2292        This method is called when a solution is found. It asserts whether the
2293        solution is valid. A value of false indicates that the solution
2294        should be discarded.
2295        """
2296        return _pywrapcp.SearchMonitor_AcceptSolution(self)
2297
2298    def AtSolution(self):
2299        r"""
2300        This method is called when a valid solution is found. If the
2301        return value is true, then search will resume after. If the result
2302        is false, then search will stop there.
2303        """
2304        return _pywrapcp.SearchMonitor_AtSolution(self)
2305
2306    def NoMoreSolutions(self):
2307        r""" When the search tree is finished."""
2308        return _pywrapcp.SearchMonitor_NoMoreSolutions(self)
2309
2310    def LocalOptimum(self):
2311        r"""
2312        When a local optimum is reached. If 'true' is returned, the last solution
2313        is discarded and the search proceeds with the next one.
2314        """
2315        return _pywrapcp.SearchMonitor_LocalOptimum(self)
2316
2317    def AcceptDelta(self, delta, deltadelta):
2318        
2319        return _pywrapcp.SearchMonitor_AcceptDelta(self, delta, deltadelta)
2320
2321    def AcceptNeighbor(self):
2322        r""" After accepting a neighbor during local search."""
2323        return _pywrapcp.SearchMonitor_AcceptNeighbor(self)
2324
2325    def solver(self):
2326        return _pywrapcp.SearchMonitor_solver(self)
2327
2328    def __repr__(self):
2329        return _pywrapcp.SearchMonitor___repr__(self)
2330
2331    def __str__(self):
2332        return _pywrapcp.SearchMonitor___str__(self)
2333    def __disown__(self):
2334        self.this.disown()
2335        _pywrapcp.disown_SearchMonitor(self)
2336        return weakref.proxy(self)
2337
2338# Register SearchMonitor in _pywrapcp:
2339_pywrapcp.SearchMonitor_swigregister(SearchMonitor)
2340class IntExpr(PropagationBaseObject):
2341    r"""
2342    The class IntExpr is the base of all integer expressions in
2343    constraint programming.
2344    It contains the basic protocol for an expression:
2345      - setting and modifying its bound
2346      - querying if it is bound
2347      - listening to events modifying its bounds
2348      - casting it into a variable (instance of IntVar)
2349    """
2350
2351    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2352
2353    def __init__(self, *args, **kwargs):
2354        raise AttributeError("No constructor defined - class is abstract")
2355
2356    def Min(self):
2357        return _pywrapcp.IntExpr_Min(self)
2358
2359    def SetMin(self, m):
2360        return _pywrapcp.IntExpr_SetMin(self, m)
2361
2362    def Max(self):
2363        return _pywrapcp.IntExpr_Max(self)
2364
2365    def SetMax(self, m):
2366        return _pywrapcp.IntExpr_SetMax(self, m)
2367
2368    def SetRange(self, l, u):
2369        r""" This method sets both the min and the max of the expression."""
2370        return _pywrapcp.IntExpr_SetRange(self, l, u)
2371
2372    def SetValue(self, v):
2373        r""" This method sets the value of the expression."""
2374        return _pywrapcp.IntExpr_SetValue(self, v)
2375
2376    def Bound(self):
2377        r""" Returns true if the min and the max of the expression are equal."""
2378        return _pywrapcp.IntExpr_Bound(self)
2379
2380    def IsVar(self):
2381        r""" Returns true if the expression is indeed a variable."""
2382        return _pywrapcp.IntExpr_IsVar(self)
2383
2384    def Var(self):
2385        r""" Creates a variable from the expression."""
2386        return _pywrapcp.IntExpr_Var(self)
2387
2388    def VarWithName(self, name):
2389        r"""
2390        Creates a variable from the expression and set the name of the
2391        resulting var. If the expression is already a variable, then it
2392        will set the name of the expression, possibly overwriting it.
2393        This is just a shortcut to Var() followed by set_name().
2394        """
2395        return _pywrapcp.IntExpr_VarWithName(self, name)
2396
2397    def WhenRange(self, *args):
2398        r"""
2399        *Overload 1:*
2400        Attach a demon that will watch the min or the max of the expression.
2401
2402        |
2403
2404        *Overload 2:*
2405        Attach a demon that will watch the min or the max of the expression.
2406        """
2407        return _pywrapcp.IntExpr_WhenRange(self, *args)
2408
2409    def __repr__(self):
2410        return _pywrapcp.IntExpr___repr__(self)
2411
2412    def __str__(self):
2413        return _pywrapcp.IntExpr___str__(self)
2414
2415    def __add__(self, *args):
2416        return _pywrapcp.IntExpr___add__(self, *args)
2417
2418    def __radd__(self, v):
2419        return _pywrapcp.IntExpr___radd__(self, v)
2420
2421    def __sub__(self, *args):
2422        return _pywrapcp.IntExpr___sub__(self, *args)
2423
2424    def __rsub__(self, v):
2425        return _pywrapcp.IntExpr___rsub__(self, v)
2426
2427    def __mul__(self, *args):
2428        return _pywrapcp.IntExpr___mul__(self, *args)
2429
2430    def __rmul__(self, v):
2431        return _pywrapcp.IntExpr___rmul__(self, v)
2432
2433    def __floordiv__(self, *args):
2434        return _pywrapcp.IntExpr___floordiv__(self, *args)
2435
2436    def __mod__(self, *args):
2437        return _pywrapcp.IntExpr___mod__(self, *args)
2438
2439    def __neg__(self):
2440        return _pywrapcp.IntExpr___neg__(self)
2441
2442    def __abs__(self):
2443        return _pywrapcp.IntExpr___abs__(self)
2444
2445    def Square(self):
2446        return _pywrapcp.IntExpr_Square(self)
2447
2448    def __eq__(self, *args):
2449        return _pywrapcp.IntExpr___eq__(self, *args)
2450
2451    def __ne__(self, *args):
2452        return _pywrapcp.IntExpr___ne__(self, *args)
2453
2454    def __ge__(self, *args):
2455        return _pywrapcp.IntExpr___ge__(self, *args)
2456
2457    def __gt__(self, *args):
2458        return _pywrapcp.IntExpr___gt__(self, *args)
2459
2460    def __le__(self, *args):
2461        return _pywrapcp.IntExpr___le__(self, *args)
2462
2463    def __lt__(self, *args):
2464        return _pywrapcp.IntExpr___lt__(self, *args)
2465
2466    def MapTo(self, vars):
2467        return _pywrapcp.IntExpr_MapTo(self, vars)
2468
2469    def IndexOf(self, *args):
2470        return _pywrapcp.IntExpr_IndexOf(self, *args)
2471
2472    def IsMember(self, values):
2473        return _pywrapcp.IntExpr_IsMember(self, values)
2474
2475    def Member(self, values):
2476        return _pywrapcp.IntExpr_Member(self, values)
2477
2478    def NotMember(self, starts, ends):
2479        return _pywrapcp.IntExpr_NotMember(self, starts, ends)
2480
2481# Register IntExpr in _pywrapcp:
2482_pywrapcp.IntExpr_swigregister(IntExpr)
2483class IntVarIterator(BaseObject):
2484    r"""
2485     The class Iterator has two direct subclasses. HoleIterators
2486     iterates over all holes, that is value removed between the
2487     current min and max of the variable since the last time the
2488     variable was processed in the queue. DomainIterators iterates
2489     over all elements of the variable domain. Both iterators are not
2490     robust to domain changes. Hole iterators can also report values outside
2491     the current min and max of the variable.
2492     HoleIterators should only be called from a demon attached to the
2493     variable that has created this iterator.
2494     IntVar* current_var;
2495     std::unique_ptr<IntVarIterator> it(current_var->MakeHoleIterator(false));
2496     for (const int64_t hole : InitAndGetValues(it)) {
2497    use the hole
2498     }
2499    """
2500
2501    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2502
2503    def __init__(self, *args, **kwargs):
2504        raise AttributeError("No constructor defined - class is abstract")
2505    __repr__ = _swig_repr
2506
2507    def Init(self):
2508        r""" This method must be called before each loop."""
2509        return _pywrapcp.IntVarIterator_Init(self)
2510
2511    def Ok(self):
2512        r""" This method indicates if we can call Value() or not."""
2513        return _pywrapcp.IntVarIterator_Ok(self)
2514
2515    def Value(self):
2516        r""" This method returns the current value of the iterator."""
2517        return _pywrapcp.IntVarIterator_Value(self)
2518
2519    def Next(self):
2520        r""" This method moves the iterator to the next value."""
2521        return _pywrapcp.IntVarIterator_Next(self)
2522
2523    def DebugString(self):
2524        r""" Pretty Print."""
2525        return _pywrapcp.IntVarIterator_DebugString(self)
2526
2527    def __iter__(self):
2528      self.Init()
2529      return self
2530
2531    def next(self):
2532      if self.Ok():
2533        result = self.Value()
2534        self.Next()
2535        return result
2536      else:
2537        raise StopIteration()
2538
2539    def __next__(self):
2540      return self.next()
2541
2542
2543# Register IntVarIterator in _pywrapcp:
2544_pywrapcp.IntVarIterator_swigregister(IntVarIterator)
2545class IntVar(IntExpr):
2546    r"""
2547    The class IntVar is a subset of IntExpr. In addition to the
2548    IntExpr protocol, it offers persistence, removing values from the domains,
2549    and a finer model for events.
2550    """
2551
2552    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2553
2554    def __init__(self, *args, **kwargs):
2555        raise AttributeError("No constructor defined - class is abstract")
2556
2557    def IsVar(self):
2558        return _pywrapcp.IntVar_IsVar(self)
2559
2560    def Var(self):
2561        return _pywrapcp.IntVar_Var(self)
2562
2563    def Value(self):
2564        r"""
2565        This method returns the value of the variable. This method checks
2566        before that the variable is bound.
2567        """
2568        return _pywrapcp.IntVar_Value(self)
2569
2570    def RemoveValue(self, v):
2571        r""" This method removes the value 'v' from the domain of the variable."""
2572        return _pywrapcp.IntVar_RemoveValue(self, v)
2573
2574    def RemoveInterval(self, l, u):
2575        r"""
2576        This method removes the interval 'l' .. 'u' from the domain of
2577        the variable. It assumes that 'l' <= 'u'.
2578        """
2579        return _pywrapcp.IntVar_RemoveInterval(self, l, u)
2580
2581    def RemoveValues(self, values):
2582        r""" This method remove the values from the domain of the variable."""
2583        return _pywrapcp.IntVar_RemoveValues(self, values)
2584
2585    def SetValues(self, values):
2586        r""" This method intersects the current domain with the values in the array."""
2587        return _pywrapcp.IntVar_SetValues(self, values)
2588
2589    def WhenBound(self, *args):
2590        r"""
2591        *Overload 1:*
2592        This method attaches a demon that will be awakened when the
2593        variable is bound.
2594
2595        |
2596
2597        *Overload 2:*
2598        This method attaches a closure that will be awakened when the
2599        variable is bound.
2600        """
2601        return _pywrapcp.IntVar_WhenBound(self, *args)
2602
2603    def WhenDomain(self, *args):
2604        r"""
2605        *Overload 1:*
2606        This method attaches a demon that will watch any domain
2607        modification of the domain of the variable.
2608
2609        |
2610
2611        *Overload 2:*
2612        This method attaches a closure that will watch any domain
2613        modification of the domain of the variable.
2614        """
2615        return _pywrapcp.IntVar_WhenDomain(self, *args)
2616
2617    def Size(self):
2618        r""" This method returns the number of values in the domain of the variable."""
2619        return _pywrapcp.IntVar_Size(self)
2620
2621    def Contains(self, v):
2622        r"""
2623        This method returns whether the value 'v' is in the domain of the
2624        variable.
2625        """
2626        return _pywrapcp.IntVar_Contains(self, v)
2627
2628    def HoleIteratorAux(self, reversible):
2629        r"""
2630        Creates a hole iterator. When 'reversible' is false, the returned
2631        object is created on the normal C++ heap and the solver does NOT
2632        take ownership of the object.
2633        """
2634        return _pywrapcp.IntVar_HoleIteratorAux(self, reversible)
2635
2636    def DomainIteratorAux(self, reversible):
2637        r"""
2638        Creates a domain iterator. When 'reversible' is false, the
2639        returned object is created on the normal C++ heap and the solver
2640        does NOT take ownership of the object.
2641        """
2642        return _pywrapcp.IntVar_DomainIteratorAux(self, reversible)
2643
2644    def OldMin(self):
2645        r""" Returns the previous min."""
2646        return _pywrapcp.IntVar_OldMin(self)
2647
2648    def OldMax(self):
2649        r""" Returns the previous max."""
2650        return _pywrapcp.IntVar_OldMax(self)
2651
2652    def __repr__(self):
2653        return _pywrapcp.IntVar___repr__(self)
2654
2655    def __str__(self):
2656        return _pywrapcp.IntVar___str__(self)
2657
2658    def DomainIterator(self):
2659      return iter(self.DomainIteratorAux(False))
2660
2661    def HoleIterator(self):
2662      return iter(self.HoleIteratorAux(False))
2663
2664
2665# Register IntVar in _pywrapcp:
2666_pywrapcp.IntVar_swigregister(IntVar)
2667class SolutionCollector(SearchMonitor):
2668    r"""
2669    This class is the root class of all solution collectors.
2670    It implements a basic query API to be used independently
2671    of the collector used.
2672    """
2673
2674    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2675
2676    def __init__(self, *args, **kwargs):
2677        raise AttributeError("No constructor defined")
2678    __repr__ = _swig_repr
2679
2680    def DebugString(self):
2681        return _pywrapcp.SolutionCollector_DebugString(self)
2682
2683    def Add(self, *args):
2684        return _pywrapcp.SolutionCollector_Add(self, *args)
2685
2686    def AddObjective(self, objective):
2687        return _pywrapcp.SolutionCollector_AddObjective(self, objective)
2688
2689    def EnterSearch(self):
2690        r""" Beginning of the search."""
2691        return _pywrapcp.SolutionCollector_EnterSearch(self)
2692
2693    def SolutionCount(self):
2694        r""" Returns how many solutions were stored during the search."""
2695        return _pywrapcp.SolutionCollector_SolutionCount(self)
2696
2697    def Solution(self, n):
2698        r""" Returns the nth solution."""
2699        return _pywrapcp.SolutionCollector_Solution(self, n)
2700
2701    def WallTime(self, n):
2702        r""" Returns the wall time in ms for the nth solution."""
2703        return _pywrapcp.SolutionCollector_WallTime(self, n)
2704
2705    def Branches(self, n):
2706        r""" Returns the number of branches when the nth solution was found."""
2707        return _pywrapcp.SolutionCollector_Branches(self, n)
2708
2709    def Failures(self, n):
2710        r"""
2711        Returns the number of failures encountered at the time of the nth
2712        solution.
2713        """
2714        return _pywrapcp.SolutionCollector_Failures(self, n)
2715
2716    def ObjectiveValue(self, n):
2717        r""" Returns the objective value of the nth solution."""
2718        return _pywrapcp.SolutionCollector_ObjectiveValue(self, n)
2719
2720    def Value(self, n, var):
2721        r""" This is a shortcut to get the Value of 'var' in the nth solution."""
2722        return _pywrapcp.SolutionCollector_Value(self, n, var)
2723
2724    def StartValue(self, n, var):
2725        r""" This is a shortcut to get the StartValue of 'var' in the nth solution."""
2726        return _pywrapcp.SolutionCollector_StartValue(self, n, var)
2727
2728    def EndValue(self, n, var):
2729        r""" This is a shortcut to get the EndValue of 'var' in the nth solution."""
2730        return _pywrapcp.SolutionCollector_EndValue(self, n, var)
2731
2732    def DurationValue(self, n, var):
2733        r""" This is a shortcut to get the DurationValue of 'var' in the nth solution."""
2734        return _pywrapcp.SolutionCollector_DurationValue(self, n, var)
2735
2736    def PerformedValue(self, n, var):
2737        r""" This is a shortcut to get the PerformedValue of 'var' in the nth solution."""
2738        return _pywrapcp.SolutionCollector_PerformedValue(self, n, var)
2739
2740    def ForwardSequence(self, n, var):
2741        r"""
2742        This is a shortcut to get the ForwardSequence of 'var' in the
2743        nth solution. The forward sequence is the list of ranked interval
2744        variables starting from the start of the sequence.
2745        """
2746        return _pywrapcp.SolutionCollector_ForwardSequence(self, n, var)
2747
2748    def BackwardSequence(self, n, var):
2749        r"""
2750        This is a shortcut to get the BackwardSequence of 'var' in the
2751        nth solution. The backward sequence is the list of ranked interval
2752        variables starting from the end of the sequence.
2753        """
2754        return _pywrapcp.SolutionCollector_BackwardSequence(self, n, var)
2755
2756    def Unperformed(self, n, var):
2757        r"""
2758        This is a shortcut to get the list of unperformed of 'var' in the
2759        nth solution.
2760        """
2761        return _pywrapcp.SolutionCollector_Unperformed(self, n, var)
2762
2763# Register SolutionCollector in _pywrapcp:
2764_pywrapcp.SolutionCollector_swigregister(SolutionCollector)
2765class OptimizeVar(SearchMonitor):
2766    r"""
2767    This class encapsulates an objective. It requires the direction
2768    (minimize or maximize), the variable to optimize, and the
2769    improvement step.
2770    """
2771
2772    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2773
2774    def __init__(self, *args, **kwargs):
2775        raise AttributeError("No constructor defined")
2776    __repr__ = _swig_repr
2777
2778    def Best(self):
2779        r""" Returns the best value found during search."""
2780        return _pywrapcp.OptimizeVar_Best(self)
2781
2782    def Var(self):
2783        r""" Returns the variable that is optimized."""
2784        return _pywrapcp.OptimizeVar_Var(self)
2785
2786    def AcceptDelta(self, delta, deltadelta):
2787        r""" Internal methods."""
2788        return _pywrapcp.OptimizeVar_AcceptDelta(self, delta, deltadelta)
2789
2790    def EnterSearch(self):
2791        return _pywrapcp.OptimizeVar_EnterSearch(self)
2792
2793    def BeginNextDecision(self, db):
2794        return _pywrapcp.OptimizeVar_BeginNextDecision(self, db)
2795
2796    def RefuteDecision(self, d):
2797        return _pywrapcp.OptimizeVar_RefuteDecision(self, d)
2798
2799    def AtSolution(self):
2800        return _pywrapcp.OptimizeVar_AtSolution(self)
2801
2802    def AcceptSolution(self):
2803        return _pywrapcp.OptimizeVar_AcceptSolution(self)
2804
2805    def DebugString(self):
2806        return _pywrapcp.OptimizeVar_DebugString(self)
2807
2808# Register OptimizeVar in _pywrapcp:
2809_pywrapcp.OptimizeVar_swigregister(OptimizeVar)
2810class SearchLimit(SearchMonitor):
2811    r""" Base class of all search limits."""
2812
2813    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2814
2815    def __init__(self, *args, **kwargs):
2816        raise AttributeError("No constructor defined - class is abstract")
2817    __repr__ = _swig_repr
2818    __swig_destroy__ = _pywrapcp.delete_SearchLimit
2819
2820    def Crossed(self):
2821        r""" Returns true if the limit has been crossed."""
2822        return _pywrapcp.SearchLimit_Crossed(self)
2823
2824    def Check(self):
2825        r"""
2826        This method is called to check the status of the limit. A return
2827        value of true indicates that we have indeed crossed the limit. In
2828        that case, this method will not be called again and the remaining
2829        search will be discarded.
2830        """
2831        return _pywrapcp.SearchLimit_Check(self)
2832
2833    def Init(self):
2834        r""" This method is called when the search limit is initialized."""
2835        return _pywrapcp.SearchLimit_Init(self)
2836
2837    def EnterSearch(self):
2838        r""" Internal methods."""
2839        return _pywrapcp.SearchLimit_EnterSearch(self)
2840
2841    def BeginNextDecision(self, b):
2842        return _pywrapcp.SearchLimit_BeginNextDecision(self, b)
2843
2844    def RefuteDecision(self, d):
2845        return _pywrapcp.SearchLimit_RefuteDecision(self, d)
2846
2847    def DebugString(self):
2848        return _pywrapcp.SearchLimit_DebugString(self)
2849
2850# Register SearchLimit in _pywrapcp:
2851_pywrapcp.SearchLimit_swigregister(SearchLimit)
2852class IntervalVar(PropagationBaseObject):
2853    r"""
2854    Interval variables are often used in scheduling. The main characteristics
2855    of an IntervalVar are the start position, duration, and end
2856    date. All these characteristics can be queried and set, and demons can
2857    be posted on their modifications.
2858
2859    An important aspect is optionality: an IntervalVar can be performed or not.
2860    If unperformed, then it simply does not exist, and its characteristics
2861    cannot be accessed any more. An interval var is automatically marked
2862    as unperformed when it is not consistent anymore (start greater
2863    than end, duration < 0...)
2864    """
2865
2866    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2867
2868    def __init__(self, *args, **kwargs):
2869        raise AttributeError("No constructor defined - class is abstract")
2870
2871    def StartMin(self):
2872        r"""
2873        These methods query, set, and watch the start position of the
2874        interval var.
2875        """
2876        return _pywrapcp.IntervalVar_StartMin(self)
2877
2878    def StartMax(self):
2879        return _pywrapcp.IntervalVar_StartMax(self)
2880
2881    def SetStartMin(self, m):
2882        return _pywrapcp.IntervalVar_SetStartMin(self, m)
2883
2884    def SetStartMax(self, m):
2885        return _pywrapcp.IntervalVar_SetStartMax(self, m)
2886
2887    def SetStartRange(self, mi, ma):
2888        return _pywrapcp.IntervalVar_SetStartRange(self, mi, ma)
2889
2890    def OldStartMin(self):
2891        return _pywrapcp.IntervalVar_OldStartMin(self)
2892
2893    def OldStartMax(self):
2894        return _pywrapcp.IntervalVar_OldStartMax(self)
2895
2896    def WhenStartRange(self, *args):
2897        return _pywrapcp.IntervalVar_WhenStartRange(self, *args)
2898
2899    def WhenStartBound(self, *args):
2900        return _pywrapcp.IntervalVar_WhenStartBound(self, *args)
2901
2902    def DurationMin(self):
2903        r""" These methods query, set, and watch the duration of the interval var."""
2904        return _pywrapcp.IntervalVar_DurationMin(self)
2905
2906    def DurationMax(self):
2907        return _pywrapcp.IntervalVar_DurationMax(self)
2908
2909    def SetDurationMin(self, m):
2910        return _pywrapcp.IntervalVar_SetDurationMin(self, m)
2911
2912    def SetDurationMax(self, m):
2913        return _pywrapcp.IntervalVar_SetDurationMax(self, m)
2914
2915    def SetDurationRange(self, mi, ma):
2916        return _pywrapcp.IntervalVar_SetDurationRange(self, mi, ma)
2917
2918    def OldDurationMin(self):
2919        return _pywrapcp.IntervalVar_OldDurationMin(self)
2920
2921    def OldDurationMax(self):
2922        return _pywrapcp.IntervalVar_OldDurationMax(self)
2923
2924    def WhenDurationRange(self, *args):
2925        return _pywrapcp.IntervalVar_WhenDurationRange(self, *args)
2926
2927    def WhenDurationBound(self, *args):
2928        return _pywrapcp.IntervalVar_WhenDurationBound(self, *args)
2929
2930    def EndMin(self):
2931        r""" These methods query, set, and watch the end position of the interval var."""
2932        return _pywrapcp.IntervalVar_EndMin(self)
2933
2934    def EndMax(self):
2935        return _pywrapcp.IntervalVar_EndMax(self)
2936
2937    def SetEndMin(self, m):
2938        return _pywrapcp.IntervalVar_SetEndMin(self, m)
2939
2940    def SetEndMax(self, m):
2941        return _pywrapcp.IntervalVar_SetEndMax(self, m)
2942
2943    def SetEndRange(self, mi, ma):
2944        return _pywrapcp.IntervalVar_SetEndRange(self, mi, ma)
2945
2946    def OldEndMin(self):
2947        return _pywrapcp.IntervalVar_OldEndMin(self)
2948
2949    def OldEndMax(self):
2950        return _pywrapcp.IntervalVar_OldEndMax(self)
2951
2952    def WhenEndRange(self, *args):
2953        return _pywrapcp.IntervalVar_WhenEndRange(self, *args)
2954
2955    def WhenEndBound(self, *args):
2956        return _pywrapcp.IntervalVar_WhenEndBound(self, *args)
2957
2958    def MustBePerformed(self):
2959        r"""
2960        These methods query, set, and watch the performed status of the
2961        interval var.
2962        """
2963        return _pywrapcp.IntervalVar_MustBePerformed(self)
2964
2965    def MayBePerformed(self):
2966        return _pywrapcp.IntervalVar_MayBePerformed(self)
2967
2968    def CannotBePerformed(self):
2969        return _pywrapcp.IntervalVar_CannotBePerformed(self)
2970
2971    def IsPerformedBound(self):
2972        return _pywrapcp.IntervalVar_IsPerformedBound(self)
2973
2974    def SetPerformed(self, val):
2975        return _pywrapcp.IntervalVar_SetPerformed(self, val)
2976
2977    def WasPerformedBound(self):
2978        return _pywrapcp.IntervalVar_WasPerformedBound(self)
2979
2980    def WhenPerformedBound(self, *args):
2981        return _pywrapcp.IntervalVar_WhenPerformedBound(self, *args)
2982
2983    def WhenAnything(self, *args):
2984        r"""
2985        *Overload 1:*
2986        Attaches a demon awakened when anything about this interval changes.
2987
2988        |
2989
2990        *Overload 2:*
2991        Attaches a closure awakened when anything about this interval changes.
2992        """
2993        return _pywrapcp.IntervalVar_WhenAnything(self, *args)
2994
2995    def StartExpr(self):
2996        r"""
2997        These methods create expressions encapsulating the start, end
2998        and duration of the interval var. Please note that these must not
2999        be used if the interval var is unperformed.
3000        """
3001        return _pywrapcp.IntervalVar_StartExpr(self)
3002
3003    def DurationExpr(self):
3004        return _pywrapcp.IntervalVar_DurationExpr(self)
3005
3006    def EndExpr(self):
3007        return _pywrapcp.IntervalVar_EndExpr(self)
3008
3009    def PerformedExpr(self):
3010        return _pywrapcp.IntervalVar_PerformedExpr(self)
3011
3012    def SafeStartExpr(self, unperformed_value):
3013        r"""
3014        These methods create expressions encapsulating the start, end
3015        and duration of the interval var. If the interval var is
3016        unperformed, they will return the unperformed_value.
3017        """
3018        return _pywrapcp.IntervalVar_SafeStartExpr(self, unperformed_value)
3019
3020    def SafeDurationExpr(self, unperformed_value):
3021        return _pywrapcp.IntervalVar_SafeDurationExpr(self, unperformed_value)
3022
3023    def SafeEndExpr(self, unperformed_value):
3024        return _pywrapcp.IntervalVar_SafeEndExpr(self, unperformed_value)
3025
3026    def EndsAfterEnd(self, other):
3027        return _pywrapcp.IntervalVar_EndsAfterEnd(self, other)
3028
3029    def EndsAfterEndWithDelay(self, other, delay):
3030        return _pywrapcp.IntervalVar_EndsAfterEndWithDelay(self, other, delay)
3031
3032    def EndsAfterStart(self, other):
3033        return _pywrapcp.IntervalVar_EndsAfterStart(self, other)
3034
3035    def EndsAfterStartWithDelay(self, other, delay):
3036        return _pywrapcp.IntervalVar_EndsAfterStartWithDelay(self, other, delay)
3037
3038    def EndsAtEnd(self, other):
3039        return _pywrapcp.IntervalVar_EndsAtEnd(self, other)
3040
3041    def EndsAtEndWithDelay(self, other, delay):
3042        return _pywrapcp.IntervalVar_EndsAtEndWithDelay(self, other, delay)
3043
3044    def EndsAtStart(self, other):
3045        return _pywrapcp.IntervalVar_EndsAtStart(self, other)
3046
3047    def EndsAtStartWithDelay(self, other, delay):
3048        return _pywrapcp.IntervalVar_EndsAtStartWithDelay(self, other, delay)
3049
3050    def StartsAfterEnd(self, other):
3051        return _pywrapcp.IntervalVar_StartsAfterEnd(self, other)
3052
3053    def StartsAfterEndWithDelay(self, other, delay):
3054        return _pywrapcp.IntervalVar_StartsAfterEndWithDelay(self, other, delay)
3055
3056    def StartsAfterStart(self, other):
3057        return _pywrapcp.IntervalVar_StartsAfterStart(self, other)
3058
3059    def StartsAfterStartWithDelay(self, other, delay):
3060        return _pywrapcp.IntervalVar_StartsAfterStartWithDelay(self, other, delay)
3061
3062    def StartsAtEnd(self, other):
3063        return _pywrapcp.IntervalVar_StartsAtEnd(self, other)
3064
3065    def StartsAtEndWithDelay(self, other, delay):
3066        return _pywrapcp.IntervalVar_StartsAtEndWithDelay(self, other, delay)
3067
3068    def StartsAtStart(self, other):
3069        return _pywrapcp.IntervalVar_StartsAtStart(self, other)
3070
3071    def StartsAtStartWithDelay(self, other, delay):
3072        return _pywrapcp.IntervalVar_StartsAtStartWithDelay(self, other, delay)
3073
3074    def StaysInSync(self, other):
3075        return _pywrapcp.IntervalVar_StaysInSync(self, other)
3076
3077    def StaysInSyncWithDelay(self, other, delay):
3078        return _pywrapcp.IntervalVar_StaysInSyncWithDelay(self, other, delay)
3079
3080    def EndsAfter(self, date):
3081        return _pywrapcp.IntervalVar_EndsAfter(self, date)
3082
3083    def EndsAt(self, date):
3084        return _pywrapcp.IntervalVar_EndsAt(self, date)
3085
3086    def EndsBefore(self, date):
3087        return _pywrapcp.IntervalVar_EndsBefore(self, date)
3088
3089    def StartsAfter(self, date):
3090        return _pywrapcp.IntervalVar_StartsAfter(self, date)
3091
3092    def StartsAt(self, date):
3093        return _pywrapcp.IntervalVar_StartsAt(self, date)
3094
3095    def StartsBefore(self, date):
3096        return _pywrapcp.IntervalVar_StartsBefore(self, date)
3097
3098    def CrossesDate(self, date):
3099        return _pywrapcp.IntervalVar_CrossesDate(self, date)
3100
3101    def AvoidsDate(self, date):
3102        return _pywrapcp.IntervalVar_AvoidsDate(self, date)
3103
3104    def __repr__(self):
3105        return _pywrapcp.IntervalVar___repr__(self)
3106
3107    def __str__(self):
3108        return _pywrapcp.IntervalVar___str__(self)
3109
3110# Register IntervalVar in _pywrapcp:
3111_pywrapcp.IntervalVar_swigregister(IntervalVar)
3112class SequenceVar(PropagationBaseObject):
3113    r"""
3114    A sequence variable is a variable whose domain is a set of possible
3115    orderings of the interval variables. It allows ordering of tasks. It
3116    has two sets of methods: ComputePossibleFirstsAndLasts(), which
3117    returns the list of interval variables that can be ranked first or
3118    last; and RankFirst/RankNotFirst/RankLast/RankNotLast, which can be
3119    used to create the search decision.
3120    """
3121
3122    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3123
3124    def __init__(self, *args, **kwargs):
3125        raise AttributeError("No constructor defined")
3126
3127    def DebugString(self):
3128        return _pywrapcp.SequenceVar_DebugString(self)
3129
3130    def RankFirst(self, index):
3131        r"""
3132        Ranks the index_th interval var first of all unranked interval
3133        vars. After that, it will no longer be considered ranked.
3134        """
3135        return _pywrapcp.SequenceVar_RankFirst(self, index)
3136
3137    def RankNotFirst(self, index):
3138        r"""
3139        Indicates that the index_th interval var will not be ranked first
3140        of all currently unranked interval vars.
3141        """
3142        return _pywrapcp.SequenceVar_RankNotFirst(self, index)
3143
3144    def RankLast(self, index):
3145        r"""
3146        Ranks the index_th interval var first of all unranked interval
3147        vars. After that, it will no longer be considered ranked.
3148        """
3149        return _pywrapcp.SequenceVar_RankLast(self, index)
3150
3151    def RankNotLast(self, index):
3152        r"""
3153        Indicates that the index_th interval var will not be ranked first
3154        of all currently unranked interval vars.
3155        """
3156        return _pywrapcp.SequenceVar_RankNotLast(self, index)
3157
3158    def Interval(self, index):
3159        r""" Returns the index_th interval of the sequence."""
3160        return _pywrapcp.SequenceVar_Interval(self, index)
3161
3162    def Next(self, index):
3163        r""" Returns the next of the index_th interval of the sequence."""
3164        return _pywrapcp.SequenceVar_Next(self, index)
3165
3166    def Size(self):
3167        r""" Returns the number of interval vars in the sequence."""
3168        return _pywrapcp.SequenceVar_Size(self)
3169
3170    def __repr__(self):
3171        return _pywrapcp.SequenceVar___repr__(self)
3172
3173    def __str__(self):
3174        return _pywrapcp.SequenceVar___str__(self)
3175
3176# Register SequenceVar in _pywrapcp:
3177_pywrapcp.SequenceVar_swigregister(SequenceVar)
3178class AssignmentElement(object):
3179    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3180
3181    def __init__(self, *args, **kwargs):
3182        raise AttributeError("No constructor defined")
3183    __repr__ = _swig_repr
3184
3185    def Activate(self):
3186        return _pywrapcp.AssignmentElement_Activate(self)
3187
3188    def Deactivate(self):
3189        return _pywrapcp.AssignmentElement_Deactivate(self)
3190
3191    def Activated(self):
3192        return _pywrapcp.AssignmentElement_Activated(self)
3193    __swig_destroy__ = _pywrapcp.delete_AssignmentElement
3194
3195# Register AssignmentElement in _pywrapcp:
3196_pywrapcp.AssignmentElement_swigregister(AssignmentElement)
3197class IntVarElement(AssignmentElement):
3198    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3199
3200    def __init__(self, *args, **kwargs):
3201        raise AttributeError("No constructor defined")
3202    __repr__ = _swig_repr
3203
3204    def Var(self):
3205        return _pywrapcp.IntVarElement_Var(self)
3206
3207    def Min(self):
3208        return _pywrapcp.IntVarElement_Min(self)
3209
3210    def SetMin(self, m):
3211        return _pywrapcp.IntVarElement_SetMin(self, m)
3212
3213    def Max(self):
3214        return _pywrapcp.IntVarElement_Max(self)
3215
3216    def SetMax(self, m):
3217        return _pywrapcp.IntVarElement_SetMax(self, m)
3218
3219    def Value(self):
3220        return _pywrapcp.IntVarElement_Value(self)
3221
3222    def Bound(self):
3223        return _pywrapcp.IntVarElement_Bound(self)
3224
3225    def SetRange(self, l, u):
3226        return _pywrapcp.IntVarElement_SetRange(self, l, u)
3227
3228    def SetValue(self, v):
3229        return _pywrapcp.IntVarElement_SetValue(self, v)
3230
3231    def __eq__(self, element):
3232        return _pywrapcp.IntVarElement___eq__(self, element)
3233
3234    def __ne__(self, element):
3235        return _pywrapcp.IntVarElement___ne__(self, element)
3236    __swig_destroy__ = _pywrapcp.delete_IntVarElement
3237
3238# Register IntVarElement in _pywrapcp:
3239_pywrapcp.IntVarElement_swigregister(IntVarElement)
3240class IntervalVarElement(AssignmentElement):
3241    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3242
3243    def __init__(self, *args, **kwargs):
3244        raise AttributeError("No constructor defined")
3245    __repr__ = _swig_repr
3246
3247    def Var(self):
3248        return _pywrapcp.IntervalVarElement_Var(self)
3249
3250    def StartMin(self):
3251        return _pywrapcp.IntervalVarElement_StartMin(self)
3252
3253    def StartMax(self):
3254        return _pywrapcp.IntervalVarElement_StartMax(self)
3255
3256    def StartValue(self):
3257        return _pywrapcp.IntervalVarElement_StartValue(self)
3258
3259    def DurationMin(self):
3260        return _pywrapcp.IntervalVarElement_DurationMin(self)
3261
3262    def DurationMax(self):
3263        return _pywrapcp.IntervalVarElement_DurationMax(self)
3264
3265    def DurationValue(self):
3266        return _pywrapcp.IntervalVarElement_DurationValue(self)
3267
3268    def EndMin(self):
3269        return _pywrapcp.IntervalVarElement_EndMin(self)
3270
3271    def EndMax(self):
3272        return _pywrapcp.IntervalVarElement_EndMax(self)
3273
3274    def EndValue(self):
3275        return _pywrapcp.IntervalVarElement_EndValue(self)
3276
3277    def PerformedMin(self):
3278        return _pywrapcp.IntervalVarElement_PerformedMin(self)
3279
3280    def PerformedMax(self):
3281        return _pywrapcp.IntervalVarElement_PerformedMax(self)
3282
3283    def PerformedValue(self):
3284        return _pywrapcp.IntervalVarElement_PerformedValue(self)
3285
3286    def SetStartMin(self, m):
3287        return _pywrapcp.IntervalVarElement_SetStartMin(self, m)
3288
3289    def SetStartMax(self, m):
3290        return _pywrapcp.IntervalVarElement_SetStartMax(self, m)
3291
3292    def SetStartRange(self, mi, ma):
3293        return _pywrapcp.IntervalVarElement_SetStartRange(self, mi, ma)
3294
3295    def SetStartValue(self, v):
3296        return _pywrapcp.IntervalVarElement_SetStartValue(self, v)
3297
3298    def SetDurationMin(self, m):
3299        return _pywrapcp.IntervalVarElement_SetDurationMin(self, m)
3300
3301    def SetDurationMax(self, m):
3302        return _pywrapcp.IntervalVarElement_SetDurationMax(self, m)
3303
3304    def SetDurationRange(self, mi, ma):
3305        return _pywrapcp.IntervalVarElement_SetDurationRange(self, mi, ma)
3306
3307    def SetDurationValue(self, v):
3308        return _pywrapcp.IntervalVarElement_SetDurationValue(self, v)
3309
3310    def SetEndMin(self, m):
3311        return _pywrapcp.IntervalVarElement_SetEndMin(self, m)
3312
3313    def SetEndMax(self, m):
3314        return _pywrapcp.IntervalVarElement_SetEndMax(self, m)
3315
3316    def SetEndRange(self, mi, ma):
3317        return _pywrapcp.IntervalVarElement_SetEndRange(self, mi, ma)
3318
3319    def SetEndValue(self, v):
3320        return _pywrapcp.IntervalVarElement_SetEndValue(self, v)
3321
3322    def SetPerformedMin(self, m):
3323        return _pywrapcp.IntervalVarElement_SetPerformedMin(self, m)
3324
3325    def SetPerformedMax(self, m):
3326        return _pywrapcp.IntervalVarElement_SetPerformedMax(self, m)
3327
3328    def SetPerformedRange(self, mi, ma):
3329        return _pywrapcp.IntervalVarElement_SetPerformedRange(self, mi, ma)
3330
3331    def SetPerformedValue(self, v):
3332        return _pywrapcp.IntervalVarElement_SetPerformedValue(self, v)
3333
3334    def __eq__(self, element):
3335        return _pywrapcp.IntervalVarElement___eq__(self, element)
3336
3337    def __ne__(self, element):
3338        return _pywrapcp.IntervalVarElement___ne__(self, element)
3339    __swig_destroy__ = _pywrapcp.delete_IntervalVarElement
3340
3341# Register IntervalVarElement in _pywrapcp:
3342_pywrapcp.IntervalVarElement_swigregister(IntervalVarElement)
3343class SequenceVarElement(AssignmentElement):
3344    r"""
3345    The SequenceVarElement stores a partial representation of ranked
3346    interval variables in the underlying sequence variable.
3347    This representation consists of three vectors:
3348      - the forward sequence. That is the list of interval variables
3349        ranked first in the sequence.  The first element of the backward
3350        sequence is the first interval in the sequence variable.
3351      - the backward sequence. That is the list of interval variables
3352        ranked last in the sequence. The first element of the backward
3353        sequence is the last interval in the sequence variable.
3354      - The list of unperformed interval variables.
3355     Furthermore, if all performed variables are ranked, then by
3356     convention, the forward_sequence will contain all such variables
3357     and the backward_sequence will be empty.
3358    """
3359
3360    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3361
3362    def __init__(self, *args, **kwargs):
3363        raise AttributeError("No constructor defined")
3364    __repr__ = _swig_repr
3365
3366    def Var(self):
3367        return _pywrapcp.SequenceVarElement_Var(self)
3368
3369    def ForwardSequence(self):
3370        return _pywrapcp.SequenceVarElement_ForwardSequence(self)
3371
3372    def BackwardSequence(self):
3373        return _pywrapcp.SequenceVarElement_BackwardSequence(self)
3374
3375    def Unperformed(self):
3376        return _pywrapcp.SequenceVarElement_Unperformed(self)
3377
3378    def SetSequence(self, forward_sequence, backward_sequence, unperformed):
3379        return _pywrapcp.SequenceVarElement_SetSequence(self, forward_sequence, backward_sequence, unperformed)
3380
3381    def SetForwardSequence(self, forward_sequence):
3382        return _pywrapcp.SequenceVarElement_SetForwardSequence(self, forward_sequence)
3383
3384    def SetBackwardSequence(self, backward_sequence):
3385        return _pywrapcp.SequenceVarElement_SetBackwardSequence(self, backward_sequence)
3386
3387    def SetUnperformed(self, unperformed):
3388        return _pywrapcp.SequenceVarElement_SetUnperformed(self, unperformed)
3389
3390    def __eq__(self, element):
3391        return _pywrapcp.SequenceVarElement___eq__(self, element)
3392
3393    def __ne__(self, element):
3394        return _pywrapcp.SequenceVarElement___ne__(self, element)
3395    __swig_destroy__ = _pywrapcp.delete_SequenceVarElement
3396
3397# Register SequenceVarElement in _pywrapcp:
3398_pywrapcp.SequenceVarElement_swigregister(SequenceVarElement)
3399class Assignment(PropagationBaseObject):
3400    r"""
3401    An Assignment is a variable -> domains mapping, used
3402    to report solutions to the user.
3403    """
3404
3405    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3406
3407    def __init__(self, *args, **kwargs):
3408        raise AttributeError("No constructor defined")
3409    __repr__ = _swig_repr
3410
3411    def Clear(self):
3412        return _pywrapcp.Assignment_Clear(self)
3413
3414    def Empty(self):
3415        return _pywrapcp.Assignment_Empty(self)
3416
3417    def Size(self):
3418        return _pywrapcp.Assignment_Size(self)
3419
3420    def NumIntVars(self):
3421        return _pywrapcp.Assignment_NumIntVars(self)
3422
3423    def NumIntervalVars(self):
3424        return _pywrapcp.Assignment_NumIntervalVars(self)
3425
3426    def NumSequenceVars(self):
3427        return _pywrapcp.Assignment_NumSequenceVars(self)
3428
3429    def Store(self):
3430        return _pywrapcp.Assignment_Store(self)
3431
3432    def Restore(self):
3433        return _pywrapcp.Assignment_Restore(self)
3434
3435    def Load(self, *args):
3436        return _pywrapcp.Assignment_Load(self, *args)
3437
3438    def Save(self, *args):
3439        return _pywrapcp.Assignment_Save(self, *args)
3440
3441    def AddObjective(self, v):
3442        return _pywrapcp.Assignment_AddObjective(self, v)
3443
3444    def Objective(self):
3445        return _pywrapcp.Assignment_Objective(self)
3446
3447    def HasObjective(self):
3448        return _pywrapcp.Assignment_HasObjective(self)
3449
3450    def ObjectiveMin(self):
3451        return _pywrapcp.Assignment_ObjectiveMin(self)
3452
3453    def ObjectiveMax(self):
3454        return _pywrapcp.Assignment_ObjectiveMax(self)
3455
3456    def ObjectiveValue(self):
3457        return _pywrapcp.Assignment_ObjectiveValue(self)
3458
3459    def ObjectiveBound(self):
3460        return _pywrapcp.Assignment_ObjectiveBound(self)
3461
3462    def SetObjectiveMin(self, m):
3463        return _pywrapcp.Assignment_SetObjectiveMin(self, m)
3464
3465    def SetObjectiveMax(self, m):
3466        return _pywrapcp.Assignment_SetObjectiveMax(self, m)
3467
3468    def SetObjectiveValue(self, value):
3469        return _pywrapcp.Assignment_SetObjectiveValue(self, value)
3470
3471    def SetObjectiveRange(self, l, u):
3472        return _pywrapcp.Assignment_SetObjectiveRange(self, l, u)
3473
3474    def Min(self, var):
3475        return _pywrapcp.Assignment_Min(self, var)
3476
3477    def Max(self, var):
3478        return _pywrapcp.Assignment_Max(self, var)
3479
3480    def Value(self, var):
3481        return _pywrapcp.Assignment_Value(self, var)
3482
3483    def Bound(self, var):
3484        return _pywrapcp.Assignment_Bound(self, var)
3485
3486    def SetMin(self, var, m):
3487        return _pywrapcp.Assignment_SetMin(self, var, m)
3488
3489    def SetMax(self, var, m):
3490        return _pywrapcp.Assignment_SetMax(self, var, m)
3491
3492    def SetRange(self, var, l, u):
3493        return _pywrapcp.Assignment_SetRange(self, var, l, u)
3494
3495    def SetValue(self, var, value):
3496        return _pywrapcp.Assignment_SetValue(self, var, value)
3497
3498    def StartMin(self, var):
3499        return _pywrapcp.Assignment_StartMin(self, var)
3500
3501    def StartMax(self, var):
3502        return _pywrapcp.Assignment_StartMax(self, var)
3503
3504    def StartValue(self, var):
3505        return _pywrapcp.Assignment_StartValue(self, var)
3506
3507    def DurationMin(self, var):
3508        return _pywrapcp.Assignment_DurationMin(self, var)
3509
3510    def DurationMax(self, var):
3511        return _pywrapcp.Assignment_DurationMax(self, var)
3512
3513    def DurationValue(self, var):
3514        return _pywrapcp.Assignment_DurationValue(self, var)
3515
3516    def EndMin(self, var):
3517        return _pywrapcp.Assignment_EndMin(self, var)
3518
3519    def EndMax(self, var):
3520        return _pywrapcp.Assignment_EndMax(self, var)
3521
3522    def EndValue(self, var):
3523        return _pywrapcp.Assignment_EndValue(self, var)
3524
3525    def PerformedMin(self, var):
3526        return _pywrapcp.Assignment_PerformedMin(self, var)
3527
3528    def PerformedMax(self, var):
3529        return _pywrapcp.Assignment_PerformedMax(self, var)
3530
3531    def PerformedValue(self, var):
3532        return _pywrapcp.Assignment_PerformedValue(self, var)
3533
3534    def SetStartMin(self, var, m):
3535        return _pywrapcp.Assignment_SetStartMin(self, var, m)
3536
3537    def SetStartMax(self, var, m):
3538        return _pywrapcp.Assignment_SetStartMax(self, var, m)
3539
3540    def SetStartRange(self, var, mi, ma):
3541        return _pywrapcp.Assignment_SetStartRange(self, var, mi, ma)
3542
3543    def SetStartValue(self, var, value):
3544        return _pywrapcp.Assignment_SetStartValue(self, var, value)
3545
3546    def SetDurationMin(self, var, m):
3547        return _pywrapcp.Assignment_SetDurationMin(self, var, m)
3548
3549    def SetDurationMax(self, var, m):
3550        return _pywrapcp.Assignment_SetDurationMax(self, var, m)
3551
3552    def SetDurationRange(self, var, mi, ma):
3553        return _pywrapcp.Assignment_SetDurationRange(self, var, mi, ma)
3554
3555    def SetDurationValue(self, var, value):
3556        return _pywrapcp.Assignment_SetDurationValue(self, var, value)
3557
3558    def SetEndMin(self, var, m):
3559        return _pywrapcp.Assignment_SetEndMin(self, var, m)
3560
3561    def SetEndMax(self, var, m):
3562        return _pywrapcp.Assignment_SetEndMax(self, var, m)
3563
3564    def SetEndRange(self, var, mi, ma):
3565        return _pywrapcp.Assignment_SetEndRange(self, var, mi, ma)
3566
3567    def SetEndValue(self, var, value):
3568        return _pywrapcp.Assignment_SetEndValue(self, var, value)
3569
3570    def SetPerformedMin(self, var, m):
3571        return _pywrapcp.Assignment_SetPerformedMin(self, var, m)
3572
3573    def SetPerformedMax(self, var, m):
3574        return _pywrapcp.Assignment_SetPerformedMax(self, var, m)
3575
3576    def SetPerformedRange(self, var, mi, ma):
3577        return _pywrapcp.Assignment_SetPerformedRange(self, var, mi, ma)
3578
3579    def SetPerformedValue(self, var, value):
3580        return _pywrapcp.Assignment_SetPerformedValue(self, var, value)
3581
3582    def Add(self, *args):
3583        return _pywrapcp.Assignment_Add(self, *args)
3584
3585    def ForwardSequence(self, var):
3586        return _pywrapcp.Assignment_ForwardSequence(self, var)
3587
3588    def BackwardSequence(self, var):
3589        return _pywrapcp.Assignment_BackwardSequence(self, var)
3590
3591    def Unperformed(self, var):
3592        return _pywrapcp.Assignment_Unperformed(self, var)
3593
3594    def SetSequence(self, var, forward_sequence, backward_sequence, unperformed):
3595        return _pywrapcp.Assignment_SetSequence(self, var, forward_sequence, backward_sequence, unperformed)
3596
3597    def SetForwardSequence(self, var, forward_sequence):
3598        return _pywrapcp.Assignment_SetForwardSequence(self, var, forward_sequence)
3599
3600    def SetBackwardSequence(self, var, backward_sequence):
3601        return _pywrapcp.Assignment_SetBackwardSequence(self, var, backward_sequence)
3602
3603    def SetUnperformed(self, var, unperformed):
3604        return _pywrapcp.Assignment_SetUnperformed(self, var, unperformed)
3605
3606    def Activate(self, *args):
3607        return _pywrapcp.Assignment_Activate(self, *args)
3608
3609    def Deactivate(self, *args):
3610        return _pywrapcp.Assignment_Deactivate(self, *args)
3611
3612    def Activated(self, *args):
3613        return _pywrapcp.Assignment_Activated(self, *args)
3614
3615    def DebugString(self):
3616        return _pywrapcp.Assignment_DebugString(self)
3617
3618    def IntVarContainer(self):
3619        return _pywrapcp.Assignment_IntVarContainer(self)
3620
3621    def MutableIntVarContainer(self):
3622        return _pywrapcp.Assignment_MutableIntVarContainer(self)
3623
3624    def IntervalVarContainer(self):
3625        return _pywrapcp.Assignment_IntervalVarContainer(self)
3626
3627    def MutableIntervalVarContainer(self):
3628        return _pywrapcp.Assignment_MutableIntervalVarContainer(self)
3629
3630    def SequenceVarContainer(self):
3631        return _pywrapcp.Assignment_SequenceVarContainer(self)
3632
3633    def MutableSequenceVarContainer(self):
3634        return _pywrapcp.Assignment_MutableSequenceVarContainer(self)
3635
3636    def __eq__(self, assignment):
3637        return _pywrapcp.Assignment___eq__(self, assignment)
3638
3639    def __ne__(self, assignment):
3640        return _pywrapcp.Assignment___ne__(self, assignment)
3641
3642# Register Assignment in _pywrapcp:
3643_pywrapcp.Assignment_swigregister(Assignment)
3644
3645def __lshift__(*args):
3646    return _pywrapcp.__lshift__(*args)
3647class Pack(Constraint):
3648    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3649
3650    def __init__(self, *args, **kwargs):
3651        raise AttributeError("No constructor defined")
3652    __repr__ = _swig_repr
3653
3654    def AddWeightedSumLessOrEqualConstantDimension(self, *args):
3655        r"""
3656        *Overload 1:*
3657        Dimensions are additional constraints than can restrict what is
3658        possible with the pack constraint. It can be used to set capacity
3659        limits, to count objects per bin, to compute unassigned
3660        penalties...
3661        This dimension imposes that for all bins b, the weighted sum
3662        (weights[i]) of all objects i assigned to 'b' is less or equal
3663        'bounds[b]'.
3664
3665        |
3666
3667        *Overload 2:*
3668        This dimension imposes that for all bins b, the weighted sum
3669        (weights->Run(i)) of all objects i assigned to 'b' is less or
3670        equal to 'bounds[b]'. Ownership of the callback is transferred to
3671        the pack constraint.
3672
3673        |
3674
3675        *Overload 3:*
3676        This dimension imposes that for all bins b, the weighted sum
3677        (weights->Run(i, b) of all objects i assigned to 'b' is less or
3678        equal to 'bounds[b]'. Ownership of the callback is transferred to
3679        the pack constraint.
3680        """
3681        return _pywrapcp.Pack_AddWeightedSumLessOrEqualConstantDimension(self, *args)
3682
3683    def AddWeightedSumEqualVarDimension(self, *args):
3684        r"""
3685        *Overload 1:*
3686        This dimension imposes that for all bins b, the weighted sum
3687        (weights[i]) of all objects i assigned to 'b' is equal to loads[b].
3688
3689        |
3690
3691        *Overload 2:*
3692        This dimension imposes that for all bins b, the weighted sum
3693        (weights->Run(i, b)) of all objects i assigned to 'b' is equal to
3694        loads[b].
3695        """
3696        return _pywrapcp.Pack_AddWeightedSumEqualVarDimension(self, *args)
3697
3698    def AddSumVariableWeightsLessOrEqualConstantDimension(self, usage, capacity):
3699        r"""
3700        This dimension imposes:
3701        forall b in bins,
3702           sum (i in items: usage[i] * is_assigned(i, b)) <= capacity[b]
3703        where is_assigned(i, b) is true if and only if item i is assigned
3704        to the bin b.
3705
3706        This can be used to model shapes of items by linking variables of
3707        the same item on parallel dimensions with an allowed assignment
3708        constraint.
3709        """
3710        return _pywrapcp.Pack_AddSumVariableWeightsLessOrEqualConstantDimension(self, usage, capacity)
3711
3712    def AddWeightedSumOfAssignedDimension(self, weights, cost_var):
3713        r"""
3714        This dimension enforces that cost_var == sum of weights[i] for
3715        all objects 'i' assigned to a bin.
3716        """
3717        return _pywrapcp.Pack_AddWeightedSumOfAssignedDimension(self, weights, cost_var)
3718
3719    def AddCountUsedBinDimension(self, count_var):
3720        r"""
3721        This dimension links 'count_var' to the actual number of bins used in the
3722        pack.
3723        """
3724        return _pywrapcp.Pack_AddCountUsedBinDimension(self, count_var)
3725
3726    def AddCountAssignedItemsDimension(self, count_var):
3727        r"""
3728        This dimension links 'count_var' to the actual number of items
3729        assigned to a bin in the pack.
3730        """
3731        return _pywrapcp.Pack_AddCountAssignedItemsDimension(self, count_var)
3732
3733    def Post(self):
3734        return _pywrapcp.Pack_Post(self)
3735
3736    def InitialPropagateWrapper(self):
3737        return _pywrapcp.Pack_InitialPropagateWrapper(self)
3738
3739    def DebugString(self):
3740        return _pywrapcp.Pack_DebugString(self)
3741
3742# Register Pack in _pywrapcp:
3743_pywrapcp.Pack_swigregister(Pack)
3744class DisjunctiveConstraint(Constraint):
3745    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3746
3747    def __init__(self, *args, **kwargs):
3748        raise AttributeError("No constructor defined - class is abstract")
3749    __repr__ = _swig_repr
3750
3751    def SequenceVar(self):
3752        r""" Creates a sequence variable from the constraint."""
3753        return _pywrapcp.DisjunctiveConstraint_SequenceVar(self)
3754
3755    def SetTransitionTime(self, transition_time):
3756        r"""
3757        Add a transition time between intervals.  It forces the distance between
3758        the end of interval a and start of interval b that follows it to be at
3759        least transition_time(a, b). This function must always return
3760        a positive or null value.
3761        """
3762        return _pywrapcp.DisjunctiveConstraint_SetTransitionTime(self, transition_time)
3763
3764    def TransitionTime(self, before_index, after_index):
3765        return _pywrapcp.DisjunctiveConstraint_TransitionTime(self, before_index, after_index)
3766
3767# Register DisjunctiveConstraint in _pywrapcp:
3768_pywrapcp.DisjunctiveConstraint_swigregister(DisjunctiveConstraint)
3769class RevInteger(object):
3770    r"""
3771    This class adds reversibility to a POD type.
3772    It contains the stamp optimization. i.e. the SaveValue call is done
3773    only once per node of the search tree.  Please note that actual
3774    stamps always starts at 1, thus an initial value of 0 will always
3775    trigger the first SaveValue.
3776    """
3777
3778    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3779    __repr__ = _swig_repr
3780
3781    def __init__(self, val):
3782        _pywrapcp.RevInteger_swiginit(self, _pywrapcp.new_RevInteger(val))
3783
3784    def Value(self):
3785        return _pywrapcp.RevInteger_Value(self)
3786
3787    def SetValue(self, s, val):
3788        return _pywrapcp.RevInteger_SetValue(self, s, val)
3789    __swig_destroy__ = _pywrapcp.delete_RevInteger
3790
3791# Register RevInteger in _pywrapcp:
3792_pywrapcp.RevInteger_swigregister(RevInteger)
3793class NumericalRevInteger(RevInteger):
3794    r""" Subclass of Rev<T> which adds numerical operations."""
3795
3796    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3797    __repr__ = _swig_repr
3798
3799    def __init__(self, val):
3800        _pywrapcp.NumericalRevInteger_swiginit(self, _pywrapcp.new_NumericalRevInteger(val))
3801
3802    def Add(self, s, to_add):
3803        return _pywrapcp.NumericalRevInteger_Add(self, s, to_add)
3804
3805    def Incr(self, s):
3806        return _pywrapcp.NumericalRevInteger_Incr(self, s)
3807
3808    def Decr(self, s):
3809        return _pywrapcp.NumericalRevInteger_Decr(self, s)
3810    __swig_destroy__ = _pywrapcp.delete_NumericalRevInteger
3811
3812# Register NumericalRevInteger in _pywrapcp:
3813_pywrapcp.NumericalRevInteger_swigregister(NumericalRevInteger)
3814class RevBool(object):
3815    r"""
3816    This class adds reversibility to a POD type.
3817    It contains the stamp optimization. i.e. the SaveValue call is done
3818    only once per node of the search tree.  Please note that actual
3819    stamps always starts at 1, thus an initial value of 0 will always
3820    trigger the first SaveValue.
3821    """
3822
3823    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3824    __repr__ = _swig_repr
3825
3826    def __init__(self, val):
3827        _pywrapcp.RevBool_swiginit(self, _pywrapcp.new_RevBool(val))
3828
3829    def Value(self):
3830        return _pywrapcp.RevBool_Value(self)
3831
3832    def SetValue(self, s, val):
3833        return _pywrapcp.RevBool_SetValue(self, s, val)
3834    __swig_destroy__ = _pywrapcp.delete_RevBool
3835
3836# Register RevBool in _pywrapcp:
3837_pywrapcp.RevBool_swigregister(RevBool)
3838class IntVarContainer(object):
3839    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3840
3841    def __init__(self, *args, **kwargs):
3842        raise AttributeError("No constructor defined")
3843    __repr__ = _swig_repr
3844
3845    def Contains(self, var):
3846        return _pywrapcp.IntVarContainer_Contains(self, var)
3847
3848    def Element(self, index):
3849        return _pywrapcp.IntVarContainer_Element(self, index)
3850
3851    def Size(self):
3852        return _pywrapcp.IntVarContainer_Size(self)
3853
3854    def Store(self):
3855        return _pywrapcp.IntVarContainer_Store(self)
3856
3857    def Restore(self):
3858        return _pywrapcp.IntVarContainer_Restore(self)
3859
3860    def __eq__(self, container):
3861        r"""
3862        Returns true if this and 'container' both represent the same V* -> E map.
3863        Runs in linear time; requires that the == operator on the type E is well
3864        defined.
3865        """
3866        return _pywrapcp.IntVarContainer___eq__(self, container)
3867
3868    def __ne__(self, container):
3869        return _pywrapcp.IntVarContainer___ne__(self, container)
3870    __swig_destroy__ = _pywrapcp.delete_IntVarContainer
3871
3872# Register IntVarContainer in _pywrapcp:
3873_pywrapcp.IntVarContainer_swigregister(IntVarContainer)
3874class IntervalVarContainer(object):
3875    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3876
3877    def __init__(self, *args, **kwargs):
3878        raise AttributeError("No constructor defined")
3879    __repr__ = _swig_repr
3880
3881    def Contains(self, var):
3882        return _pywrapcp.IntervalVarContainer_Contains(self, var)
3883
3884    def Element(self, index):
3885        return _pywrapcp.IntervalVarContainer_Element(self, index)
3886
3887    def Size(self):
3888        return _pywrapcp.IntervalVarContainer_Size(self)
3889
3890    def Store(self):
3891        return _pywrapcp.IntervalVarContainer_Store(self)
3892
3893    def Restore(self):
3894        return _pywrapcp.IntervalVarContainer_Restore(self)
3895
3896    def __eq__(self, container):
3897        r"""
3898        Returns true if this and 'container' both represent the same V* -> E map.
3899        Runs in linear time; requires that the == operator on the type E is well
3900        defined.
3901        """
3902        return _pywrapcp.IntervalVarContainer___eq__(self, container)
3903
3904    def __ne__(self, container):
3905        return _pywrapcp.IntervalVarContainer___ne__(self, container)
3906    __swig_destroy__ = _pywrapcp.delete_IntervalVarContainer
3907
3908# Register IntervalVarContainer in _pywrapcp:
3909_pywrapcp.IntervalVarContainer_swigregister(IntervalVarContainer)
3910class SequenceVarContainer(object):
3911    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3912
3913    def __init__(self, *args, **kwargs):
3914        raise AttributeError("No constructor defined")
3915    __repr__ = _swig_repr
3916
3917    def Contains(self, var):
3918        return _pywrapcp.SequenceVarContainer_Contains(self, var)
3919
3920    def Element(self, index):
3921        return _pywrapcp.SequenceVarContainer_Element(self, index)
3922
3923    def Size(self):
3924        return _pywrapcp.SequenceVarContainer_Size(self)
3925
3926    def Store(self):
3927        return _pywrapcp.SequenceVarContainer_Store(self)
3928
3929    def Restore(self):
3930        return _pywrapcp.SequenceVarContainer_Restore(self)
3931
3932    def __eq__(self, container):
3933        r"""
3934        Returns true if this and 'container' both represent the same V* -> E map.
3935        Runs in linear time; requires that the == operator on the type E is well
3936        defined.
3937        """
3938        return _pywrapcp.SequenceVarContainer___eq__(self, container)
3939
3940    def __ne__(self, container):
3941        return _pywrapcp.SequenceVarContainer___ne__(self, container)
3942    __swig_destroy__ = _pywrapcp.delete_SequenceVarContainer
3943
3944# Register SequenceVarContainer in _pywrapcp:
3945_pywrapcp.SequenceVarContainer_swigregister(SequenceVarContainer)
3946class LocalSearchOperator(BaseObject):
3947    r"""
3948    The base class for all local search operators.
3949
3950    A local search operator is an object that defines the neighborhood of a
3951    solution. In other words, a neighborhood is the set of solutions which can
3952    be reached from a given solution using an operator.
3953
3954    The behavior of the LocalSearchOperator class is similar to iterators.
3955    The operator is synchronized with an assignment (gives the
3956    current values of the variables); this is done in the Start() method.
3957
3958    Then one can iterate over the neighbors using the MakeNextNeighbor method.
3959    This method returns an assignment which represents the incremental changes
3960    to the current solution. It also returns a second assignment representing
3961    the changes to the last solution defined by the neighborhood operator; this
3962    assignment is empty if the neighborhood operator cannot track this
3963    information.
3964    """
3965
3966    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3967
3968    def __init__(self, *args, **kwargs):
3969        raise AttributeError("No constructor defined - class is abstract")
3970    __repr__ = _swig_repr
3971
3972    def NextNeighbor(self, delta, deltadelta):
3973        return _pywrapcp.LocalSearchOperator_NextNeighbor(self, delta, deltadelta)
3974
3975    def Start(self, assignment):
3976        return _pywrapcp.LocalSearchOperator_Start(self, assignment)
3977    def __disown__(self):
3978        self.this.disown()
3979        _pywrapcp.disown_LocalSearchOperator(self)
3980        return weakref.proxy(self)
3981
3982# Register LocalSearchOperator in _pywrapcp:
3983_pywrapcp.LocalSearchOperator_swigregister(LocalSearchOperator)
3984class IntVarLocalSearchOperator(LocalSearchOperator):
3985    r"""
3986    Specialization of LocalSearchOperator built from an array of IntVars
3987    which specifies the scope of the operator.
3988    This class also takes care of storing current variable values in Start(),
3989    keeps track of changes done by the operator and builds the delta.
3990    The Deactivate() method can be used to perform Large Neighborhood Search.
3991    """
3992
3993    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3994    __repr__ = _swig_repr
3995
3996    def __init__(self, vars, keep_inverse_values=False):
3997        if self.__class__ == IntVarLocalSearchOperator:
3998            _self = None
3999        else:
4000            _self = self
4001        _pywrapcp.IntVarLocalSearchOperator_swiginit(self, _pywrapcp.new_IntVarLocalSearchOperator(_self, vars, keep_inverse_values))
4002    __swig_destroy__ = _pywrapcp.delete_IntVarLocalSearchOperator
4003
4004    def Start(self, assignment):
4005        r"""
4006        This method should not be overridden. Override OnStart() instead which is
4007        called before exiting this method.
4008        """
4009        return _pywrapcp.IntVarLocalSearchOperator_Start(self, assignment)
4010
4011    def IsIncremental(self):
4012        return _pywrapcp.IntVarLocalSearchOperator_IsIncremental(self)
4013
4014    def Size(self):
4015        return _pywrapcp.IntVarLocalSearchOperator_Size(self)
4016
4017    def Value(self, index):
4018        r"""
4019        Returns the value in the current assignment of the variable of given
4020        index.
4021        """
4022        return _pywrapcp.IntVarLocalSearchOperator_Value(self, index)
4023
4024    def Var(self, index):
4025        r""" Returns the variable of given index."""
4026        return _pywrapcp.IntVarLocalSearchOperator_Var(self, index)
4027
4028    def OldValue(self, index):
4029        return _pywrapcp.IntVarLocalSearchOperator_OldValue(self, index)
4030
4031    def PrevValue(self, index):
4032        return _pywrapcp.IntVarLocalSearchOperator_PrevValue(self, index)
4033
4034    def SetValue(self, index, value):
4035        return _pywrapcp.IntVarLocalSearchOperator_SetValue(self, index, value)
4036
4037    def Activated(self, index):
4038        return _pywrapcp.IntVarLocalSearchOperator_Activated(self, index)
4039
4040    def Activate(self, index):
4041        return _pywrapcp.IntVarLocalSearchOperator_Activate(self, index)
4042
4043    def Deactivate(self, index):
4044        return _pywrapcp.IntVarLocalSearchOperator_Deactivate(self, index)
4045
4046    def AddVars(self, vars):
4047        return _pywrapcp.IntVarLocalSearchOperator_AddVars(self, vars)
4048
4049    def OnStart(self):
4050        r"""
4051        Called by Start() after synchronizing the operator with the current
4052        assignment. Should be overridden instead of Start() to avoid calling
4053        IntVarLocalSearchOperator::Start explicitly.
4054        """
4055        return _pywrapcp.IntVarLocalSearchOperator_OnStart(self)
4056
4057    def NextNeighbor(self, delta, deltadelta):
4058        r"""
4059        OnStart() should really be protected, but then SWIG doesn't see it. So we
4060        make it public, but only subclasses should access to it (to override it).
4061        Redefines MakeNextNeighbor to export a simpler interface. The calls to
4062        ApplyChanges() and RevertChanges() are factored in this method, hiding
4063        both delta and deltadelta from subclasses which only need to override
4064        MakeOneNeighbor().
4065        Therefore this method should not be overridden. Override MakeOneNeighbor()
4066        instead.
4067        """
4068        return _pywrapcp.IntVarLocalSearchOperator_NextNeighbor(self, delta, deltadelta)
4069
4070    def OneNeighbor(self):
4071        r"""
4072        Creates a new neighbor. It returns false when the neighborhood is
4073        completely explored.
4074        MakeNextNeighbor() in a subclass of IntVarLocalSearchOperator.
4075        """
4076        return _pywrapcp.IntVarLocalSearchOperator_OneNeighbor(self)
4077    def __disown__(self):
4078        self.this.disown()
4079        _pywrapcp.disown_IntVarLocalSearchOperator(self)
4080        return weakref.proxy(self)
4081
4082# Register IntVarLocalSearchOperator in _pywrapcp:
4083_pywrapcp.IntVarLocalSearchOperator_swigregister(IntVarLocalSearchOperator)
4084class BaseLns(IntVarLocalSearchOperator):
4085    r"""
4086    This is the base class for building an Lns operator. An Lns fragment is a
4087    collection of variables which will be relaxed. Fragments are built with
4088    NextFragment(), which returns false if there are no more fragments to build.
4089    Optionally one can override InitFragments, which is called from
4090    LocalSearchOperator::Start to initialize fragment data.
4091
4092    Here's a sample relaxing one variable at a time:
4093
4094    class OneVarLns : public BaseLns {
4095     public:
4096      OneVarLns(const std::vector<IntVar*>& vars) : BaseLns(vars), index_(0) {}
4097      virtual ~OneVarLns() {}
4098      virtual void InitFragments() { index_ = 0; }
4099      virtual bool NextFragment() {
4100        const int size = Size();
4101        if (index_ < size) {
4102          AppendToFragment(index_);
4103          ++index_;
4104          return true;
4105        } else {
4106          return false;
4107        }
4108      }
4109
4110     private:
4111      int index_;
4112    };
4113    """
4114
4115    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4116    __repr__ = _swig_repr
4117
4118    def __init__(self, vars):
4119        if self.__class__ == BaseLns:
4120            _self = None
4121        else:
4122            _self = self
4123        _pywrapcp.BaseLns_swiginit(self, _pywrapcp.new_BaseLns(_self, vars))
4124    __swig_destroy__ = _pywrapcp.delete_BaseLns
4125
4126    def InitFragments(self):
4127        return _pywrapcp.BaseLns_InitFragments(self)
4128
4129    def NextFragment(self):
4130        return _pywrapcp.BaseLns_NextFragment(self)
4131
4132    def AppendToFragment(self, index):
4133        return _pywrapcp.BaseLns_AppendToFragment(self, index)
4134
4135    def FragmentSize(self):
4136        return _pywrapcp.BaseLns_FragmentSize(self)
4137
4138    def __getitem__(self, index):
4139        return _pywrapcp.BaseLns___getitem__(self, index)
4140
4141    def __len__(self):
4142        return _pywrapcp.BaseLns___len__(self)
4143    def __disown__(self):
4144        self.this.disown()
4145        _pywrapcp.disown_BaseLns(self)
4146        return weakref.proxy(self)
4147
4148# Register BaseLns in _pywrapcp:
4149_pywrapcp.BaseLns_swigregister(BaseLns)
4150class ChangeValue(IntVarLocalSearchOperator):
4151    r"""
4152    Defines operators which change the value of variables;
4153    each neighbor corresponds to *one* modified variable.
4154    Sub-classes have to define ModifyValue which determines what the new
4155    variable value is going to be (given the current value and the variable).
4156    """
4157
4158    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4159    __repr__ = _swig_repr
4160
4161    def __init__(self, vars):
4162        if self.__class__ == ChangeValue:
4163            _self = None
4164        else:
4165            _self = self
4166        _pywrapcp.ChangeValue_swiginit(self, _pywrapcp.new_ChangeValue(_self, vars))
4167    __swig_destroy__ = _pywrapcp.delete_ChangeValue
4168
4169    def ModifyValue(self, index, value):
4170        return _pywrapcp.ChangeValue_ModifyValue(self, index, value)
4171
4172    def OneNeighbor(self):
4173        r""" This method should not be overridden. Override ModifyValue() instead."""
4174        return _pywrapcp.ChangeValue_OneNeighbor(self)
4175    def __disown__(self):
4176        self.this.disown()
4177        _pywrapcp.disown_ChangeValue(self)
4178        return weakref.proxy(self)
4179
4180# Register ChangeValue in _pywrapcp:
4181_pywrapcp.ChangeValue_swigregister(ChangeValue)
4182class PathOperator(IntVarLocalSearchOperator):
4183    r"""
4184    Base class of the local search operators dedicated to path modifications
4185    (a path is a set of nodes linked together by arcs).
4186    This family of neighborhoods supposes they are handling next variables
4187    representing the arcs (var[i] represents the node immediately after i on
4188    a path).
4189    Several services are provided:
4190    - arc manipulators (SetNext(), ReverseChain(), MoveChain())
4191    - path inspectors (Next(), Prev(), IsPathEnd())
4192    - path iterators: operators need a given number of nodes to define a
4193      neighbor; this class provides the iteration on a given number of (base)
4194      nodes which can be used to define a neighbor (through the BaseNode method)
4195    Subclasses only need to override MakeNeighbor to create neighbors using
4196    the services above (no direct manipulation of assignments).
4197    """
4198
4199    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4200
4201    def __init__(self, *args, **kwargs):
4202        raise AttributeError("No constructor defined - class is abstract")
4203    __repr__ = _swig_repr
4204
4205    def Neighbor(self):
4206        return _pywrapcp.PathOperator_Neighbor(self)
4207
4208# Register PathOperator in _pywrapcp:
4209_pywrapcp.PathOperator_swigregister(PathOperator)
4210class LocalSearchFilter(BaseObject):
4211    r"""
4212    Classes to which this template function can be applied to as of 04/2014.
4213    Usage: LocalSearchOperator* op = MakeLocalSearchOperator<Relocate>(...);
4214    class TwoOpt;
4215    class Relocate;
4216    class Exchange;
4217    class Cross;
4218    class MakeActiveOperator;
4219    class MakeInactiveOperator;
4220    class MakeChainInactiveOperator;
4221    class SwapActiveOperator;
4222    class ExtendedSwapActiveOperator;
4223    class MakeActiveAndRelocate;
4224    class RelocateAndMakeActiveOperator;
4225    class RelocateAndMakeInactiveOperator;
4226    Local Search Filters are used for fast neighbor pruning.
4227    Filtering a move is done in several phases:
4228    - in the Relax phase, filters determine which parts of their internals
4229      will be changed by the candidate, and modify intermediary State
4230    - in the Accept phase, filters check that the candidate is feasible,
4231    - if the Accept phase succeeds, the solver may decide to trigger a
4232      Synchronize phase that makes filters change their internal representation
4233      to the last candidate,
4234    - otherwise (Accept fails or the solver does not want to synchronize),
4235      a Revert phase makes filters erase any intermediary State generated by the
4236      Relax and Accept phases.
4237    A given filter has phases called with the following pattern:
4238    (Relax.Accept.Synchronize | Relax.Accept.Revert | Relax.Revert)*.
4239    Filters's Revert() is always called in the reverse order their Accept() was
4240    called, to allow late filters to use state done/undone by early filters'
4241    Accept()/Revert().
4242    """
4243
4244    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4245
4246    def __init__(self, *args, **kwargs):
4247        raise AttributeError("No constructor defined - class is abstract")
4248    __repr__ = _swig_repr
4249
4250    def Accept(self, delta, deltadelta, objective_min, objective_max):
4251        r"""
4252        Accepts a "delta" given the assignment with which the filter has been
4253        synchronized; the delta holds the variables which have been modified and
4254        their new value.
4255        If the filter represents a part of the global objective, its contribution
4256        must be between objective_min and objective_max.
4257        Sample: supposing one wants to maintain a[0,1] + b[0,1] <= 1,
4258        for the assignment (a,1), (b,0), the delta (b,1) will be rejected
4259        but the delta (a,0) will be accepted.
4260        TODO(user): Remove arguments when there are no more need for those.
4261        """
4262        return _pywrapcp.LocalSearchFilter_Accept(self, delta, deltadelta, objective_min, objective_max)
4263
4264    def IsIncremental(self):
4265        return _pywrapcp.LocalSearchFilter_IsIncremental(self)
4266
4267    def Synchronize(self, assignment, delta):
4268        r"""
4269        Synchronizes the filter with the current solution, delta being the
4270        difference with the solution passed to the previous call to Synchronize()
4271        or IncrementalSynchronize(). 'delta' can be used to incrementally
4272        synchronizing the filter with the new solution by only considering the
4273        changes in delta.
4274        """
4275        return _pywrapcp.LocalSearchFilter_Synchronize(self, assignment, delta)
4276    __swig_destroy__ = _pywrapcp.delete_LocalSearchFilter
4277
4278# Register LocalSearchFilter in _pywrapcp:
4279_pywrapcp.LocalSearchFilter_swigregister(LocalSearchFilter)
4280class LocalSearchFilterManager(BaseObject):
4281    r"""
4282    Filter manager: when a move is made, filters are executed to decide whether
4283    the solution is feasible and compute parts of the new cost. This class
4284    schedules filter execution and composes costs as a sum.
4285    """
4286
4287    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4288    __repr__ = _swig_repr
4289
4290    def DebugString(self):
4291        return _pywrapcp.LocalSearchFilterManager_DebugString(self)
4292
4293    def __init__(self, *args):
4294        _pywrapcp.LocalSearchFilterManager_swiginit(self, _pywrapcp.new_LocalSearchFilterManager(*args))
4295
4296    def Accept(self, monitor, delta, deltadelta, objective_min, objective_max):
4297        r"""
4298        Returns true iff all filters return true, and the sum of their accepted
4299        objectives is between objective_min and objective_max.
4300        The monitor has its Begin/EndFiltering events triggered.
4301        """
4302        return _pywrapcp.LocalSearchFilterManager_Accept(self, monitor, delta, deltadelta, objective_min, objective_max)
4303
4304    def Synchronize(self, assignment, delta):
4305        r""" Synchronizes all filters to assignment."""
4306        return _pywrapcp.LocalSearchFilterManager_Synchronize(self, assignment, delta)
4307    __swig_destroy__ = _pywrapcp.delete_LocalSearchFilterManager
4308
4309# Register LocalSearchFilterManager in _pywrapcp:
4310_pywrapcp.LocalSearchFilterManager_swigregister(LocalSearchFilterManager)
4311class IntVarLocalSearchFilter(LocalSearchFilter):
4312    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4313    __repr__ = _swig_repr
4314
4315    def __init__(self, vars):
4316        if self.__class__ == IntVarLocalSearchFilter:
4317            _self = None
4318        else:
4319            _self = self
4320        _pywrapcp.IntVarLocalSearchFilter_swiginit(self, _pywrapcp.new_IntVarLocalSearchFilter(_self, vars))
4321    __swig_destroy__ = _pywrapcp.delete_IntVarLocalSearchFilter
4322
4323    def Synchronize(self, assignment, delta):
4324        r"""
4325        This method should not be overridden. Override OnSynchronize() instead
4326        which is called before exiting this method.
4327        """
4328        return _pywrapcp.IntVarLocalSearchFilter_Synchronize(self, assignment, delta)
4329
4330    def Size(self):
4331        return _pywrapcp.IntVarLocalSearchFilter_Size(self)
4332
4333    def Value(self, index):
4334        return _pywrapcp.IntVarLocalSearchFilter_Value(self, index)
4335
4336    def IndexFromVar(self, var):
4337        return _pywrapcp.IntVarLocalSearchFilter_IndexFromVar(self, var)
4338    def __disown__(self):
4339        self.this.disown()
4340        _pywrapcp.disown_IntVarLocalSearchFilter(self)
4341        return weakref.proxy(self)
4342
4343# Register IntVarLocalSearchFilter in _pywrapcp:
4344_pywrapcp.IntVarLocalSearchFilter_swigregister(IntVarLocalSearchFilter)
4345class BooleanVar(IntVar):
4346    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4347
4348    def __init__(self, *args, **kwargs):
4349        raise AttributeError("No constructor defined - class is abstract")
4350    __repr__ = _swig_repr
4351
4352    def Min(self):
4353        return _pywrapcp.BooleanVar_Min(self)
4354
4355    def SetMin(self, m):
4356        return _pywrapcp.BooleanVar_SetMin(self, m)
4357
4358    def Max(self):
4359        return _pywrapcp.BooleanVar_Max(self)
4360
4361    def SetMax(self, m):
4362        return _pywrapcp.BooleanVar_SetMax(self, m)
4363
4364    def SetRange(self, mi, ma):
4365        return _pywrapcp.BooleanVar_SetRange(self, mi, ma)
4366
4367    def Bound(self):
4368        return _pywrapcp.BooleanVar_Bound(self)
4369
4370    def Value(self):
4371        return _pywrapcp.BooleanVar_Value(self)
4372
4373    def RemoveValue(self, v):
4374        return _pywrapcp.BooleanVar_RemoveValue(self, v)
4375
4376    def RemoveInterval(self, l, u):
4377        return _pywrapcp.BooleanVar_RemoveInterval(self, l, u)
4378
4379    def WhenBound(self, d):
4380        return _pywrapcp.BooleanVar_WhenBound(self, d)
4381
4382    def WhenRange(self, d):
4383        return _pywrapcp.BooleanVar_WhenRange(self, d)
4384
4385    def WhenDomain(self, d):
4386        return _pywrapcp.BooleanVar_WhenDomain(self, d)
4387
4388    def Size(self):
4389        return _pywrapcp.BooleanVar_Size(self)
4390
4391    def Contains(self, v):
4392        return _pywrapcp.BooleanVar_Contains(self, v)
4393
4394    def HoleIteratorAux(self, reversible):
4395        return _pywrapcp.BooleanVar_HoleIteratorAux(self, reversible)
4396
4397    def DomainIteratorAux(self, reversible):
4398        return _pywrapcp.BooleanVar_DomainIteratorAux(self, reversible)
4399
4400    def DebugString(self):
4401        return _pywrapcp.BooleanVar_DebugString(self)
4402
4403# Register BooleanVar in _pywrapcp:
4404_pywrapcp.BooleanVar_swigregister(BooleanVar)
4405
4406class PyDecision(Decision):
4407
4408  def __init__(self):
4409    Decision.__init__(self)
4410
4411  def ApplyWrapper(self, solver):
4412    try:
4413       self.Apply(solver)
4414    except Exception as e:
4415      if 'CP Solver fail' in str(e):
4416        solver.ShouldFail()
4417      else:
4418        raise
4419
4420  def RefuteWrapper(self, solver):
4421    try:
4422       self.Refute(solver)
4423    except Exception as e:
4424      if 'CP Solver fail' in str(e):
4425        solver.ShouldFail()
4426      else:
4427        raise
4428
4429  def DebugString(self):
4430    return "PyDecision"
4431
4432
4433class PyDecisionBuilder(DecisionBuilder):
4434
4435  def __init__(self):
4436    DecisionBuilder.__init__(self)
4437
4438  def NextWrapper(self, solver):
4439    try:
4440      return self.Next(solver)
4441    except Exception as e:
4442      if 'CP Solver fail' in str(e):
4443        return solver.FailDecision()
4444      else:
4445        raise
4446
4447  def DebugString(self):
4448    return "PyDecisionBuilder"
4449
4450
4451class PyDemon(Demon):
4452
4453  def RunWrapper(self, solver):
4454    try:
4455      self.Run(solver)
4456    except Exception as e:
4457      if 'CP Solver fail' in str(e):
4458        solver.ShouldFail()
4459      else:
4460        raise
4461
4462  def DebugString(self):
4463    return "PyDemon"
4464
4465
4466class PyConstraintDemon(PyDemon):
4467
4468  def __init__(self, ct, method, delayed, *args):
4469    PyDemon.__init__(self)
4470    self.__constraint = ct
4471    self.__method = method
4472    self.__delayed = delayed
4473    self.__args = args
4474
4475  def Run(self, solver):
4476    self.__method(self.__constraint, *self.__args)
4477
4478  def Priority(self):
4479    return Solver.DELAYED_PRIORITY if self.__delayed else Solver.NORMAL_PRIORITY
4480
4481  def DebugString(self):
4482    return 'PyConstraintDemon'
4483
4484
4485class PyConstraint(Constraint):
4486
4487  def __init__(self, solver):
4488    Constraint.__init__(self, solver)
4489    self.__demons = []
4490
4491  def Demon(self, method, *args):
4492    demon = PyConstraintDemon(self, method, False, *args)
4493    self.__demons.append(demon)
4494    return demon
4495
4496  def DelayedDemon(self, method, *args):
4497    demon = PyConstraintDemon(self, method, True, *args)
4498    self.__demons.append(demon)
4499    return demon
4500
4501  def InitialPropagateDemon(self):
4502    return self.solver().ConstraintInitialPropagateCallback(self)
4503
4504  def DelayedInitialPropagateDemon(self):
4505    return self.solver().DelayedConstraintInitialPropagateCallback(self)
4506
4507  def InitialPropagateWrapper(self):
4508    try:
4509      self.InitialPropagate()
4510    except Exception as e:
4511      if 'CP Solver fail' in str(e):
4512        self.solver().ShouldFail()
4513      else:
4514        raise
4515
4516  def DebugString(self):
4517    return "PyConstraint"
4518
4519
4520
4521class RoutingIndexManager(object):
4522    r"""
4523    Manager for any NodeIndex <-> variable index conversion. The routing solver
4524    uses variable indices internally and through its API. These variable indices
4525    are tricky to manage directly because one Node can correspond to a multitude
4526    of variables, depending on the number of times they appear in the model, and
4527    if they're used as start and/or end points. This class aims to simplify
4528    variable index usage, allowing users to use NodeIndex instead.
4529
4530    Usage:
4531
4532      .. code-block:: c++
4533
4534          auto starts_ends = ...;  /// These are NodeIndex.
4535          RoutingIndexManager manager(10, 4, starts_ends);  // 10 nodes, 4 vehicles.
4536          RoutingModel model(manager);
4537
4538    Then, use 'manager.NodeToIndex(node)' whenever model requires a variable
4539    index.
4540
4541    Note: the mapping between node indices and variables indices is subject to
4542    change so no assumption should be made on it. The only guarantee is that
4543    indices range between 0 and n-1, where n = number of vehicles * 2 (for start
4544    and end nodes) + number of non-start or end nodes.
4545    """
4546
4547    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4548    __repr__ = _swig_repr
4549
4550    def __init__(self, *args):
4551        _pywrapcp.RoutingIndexManager_swiginit(self, _pywrapcp.new_RoutingIndexManager(*args))
4552    __swig_destroy__ = _pywrapcp.delete_RoutingIndexManager
4553
4554    def GetNumberOfNodes(self):
4555        return _pywrapcp.RoutingIndexManager_GetNumberOfNodes(self)
4556
4557    def GetNumberOfVehicles(self):
4558        return _pywrapcp.RoutingIndexManager_GetNumberOfVehicles(self)
4559
4560    def GetNumberOfIndices(self):
4561        return _pywrapcp.RoutingIndexManager_GetNumberOfIndices(self)
4562
4563    def GetStartIndex(self, vehicle):
4564        return _pywrapcp.RoutingIndexManager_GetStartIndex(self, vehicle)
4565
4566    def GetEndIndex(self, vehicle):
4567        return _pywrapcp.RoutingIndexManager_GetEndIndex(self, vehicle)
4568
4569    def NodeToIndex(self, node):
4570        return _pywrapcp.RoutingIndexManager_NodeToIndex(self, node)
4571
4572    def IndexToNode(self, index):
4573        return _pywrapcp.RoutingIndexManager_IndexToNode(self, index)
4574
4575# Register RoutingIndexManager in _pywrapcp:
4576_pywrapcp.RoutingIndexManager_swigregister(RoutingIndexManager)
4577
4578def DefaultRoutingModelParameters():
4579    return _pywrapcp.DefaultRoutingModelParameters()
4580
4581def DefaultRoutingSearchParameters():
4582    return _pywrapcp.DefaultRoutingSearchParameters()
4583
4584def FindErrorInRoutingSearchParameters(search_parameters):
4585    r"""
4586    Returns an empty std::string if the routing search parameters are valid, and
4587    a non-empty, human readable error description if they're not.
4588    """
4589    return _pywrapcp.FindErrorInRoutingSearchParameters(search_parameters)
4590BOOL_UNSPECIFIED = _pywrapcp.BOOL_UNSPECIFIED
4591BOOL_FALSE = _pywrapcp.BOOL_FALSE
4592BOOL_TRUE = _pywrapcp.BOOL_TRUE
4593class FirstSolutionStrategy(object):
4594    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4595    __repr__ = _swig_repr
4596
4597    def __init__(self):
4598        _pywrapcp.FirstSolutionStrategy_swiginit(self, _pywrapcp.new_FirstSolutionStrategy())
4599    __swig_destroy__ = _pywrapcp.delete_FirstSolutionStrategy
4600
4601# Register FirstSolutionStrategy in _pywrapcp:
4602_pywrapcp.FirstSolutionStrategy_swigregister(FirstSolutionStrategy)
4603class LocalSearchMetaheuristic(object):
4604    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4605    __repr__ = _swig_repr
4606
4607    def __init__(self):
4608        _pywrapcp.LocalSearchMetaheuristic_swiginit(self, _pywrapcp.new_LocalSearchMetaheuristic())
4609    __swig_destroy__ = _pywrapcp.delete_LocalSearchMetaheuristic
4610
4611# Register LocalSearchMetaheuristic in _pywrapcp:
4612_pywrapcp.LocalSearchMetaheuristic_swigregister(LocalSearchMetaheuristic)
4613class PathsMetadata(object):
4614    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4615    __repr__ = _swig_repr
4616
4617    def __init__(self, manager):
4618        _pywrapcp.PathsMetadata_swiginit(self, _pywrapcp.new_PathsMetadata(manager))
4619
4620    def IsStart(self, node):
4621        return _pywrapcp.PathsMetadata_IsStart(self, node)
4622
4623    def IsEnd(self, node):
4624        return _pywrapcp.PathsMetadata_IsEnd(self, node)
4625
4626    def GetPath(self, start_or_end_node):
4627        return _pywrapcp.PathsMetadata_GetPath(self, start_or_end_node)
4628
4629    def Starts(self):
4630        return _pywrapcp.PathsMetadata_Starts(self)
4631
4632    def Ends(self):
4633        return _pywrapcp.PathsMetadata_Ends(self)
4634    __swig_destroy__ = _pywrapcp.delete_PathsMetadata
4635
4636# Register PathsMetadata in _pywrapcp:
4637_pywrapcp.PathsMetadata_swigregister(PathsMetadata)
4638class RoutingModel(object):
4639    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4640    __repr__ = _swig_repr
4641    ROUTING_NOT_SOLVED = _pywrapcp.RoutingModel_ROUTING_NOT_SOLVED
4642    r""" Problem not solved yet (before calling RoutingModel::Solve())."""
4643    ROUTING_SUCCESS = _pywrapcp.RoutingModel_ROUTING_SUCCESS
4644    r""" Problem solved successfully after calling RoutingModel::Solve()."""
4645    ROUTING_PARTIAL_SUCCESS_LOCAL_OPTIMUM_NOT_REACHED = _pywrapcp.RoutingModel_ROUTING_PARTIAL_SUCCESS_LOCAL_OPTIMUM_NOT_REACHED
4646    r"""
4647    Problem solved successfully after calling RoutingModel::Solve(), except
4648    that a local optimum has not been reached. Leaving more time would allow
4649    improving the solution.
4650    """
4651    ROUTING_FAIL = _pywrapcp.RoutingModel_ROUTING_FAIL
4652    r""" No solution found to the problem after calling RoutingModel::Solve()."""
4653    ROUTING_FAIL_TIMEOUT = _pywrapcp.RoutingModel_ROUTING_FAIL_TIMEOUT
4654    r""" Time limit reached before finding a solution with RoutingModel::Solve()."""
4655    ROUTING_INVALID = _pywrapcp.RoutingModel_ROUTING_INVALID
4656    r""" Model, model parameters or flags are not valid."""
4657    ROUTING_INFEASIBLE = _pywrapcp.RoutingModel_ROUTING_INFEASIBLE
4658    r""" Problem proven to be infeasible."""
4659    PICKUP_AND_DELIVERY_NO_ORDER = _pywrapcp.RoutingModel_PICKUP_AND_DELIVERY_NO_ORDER
4660    r""" Any precedence is accepted."""
4661    PICKUP_AND_DELIVERY_LIFO = _pywrapcp.RoutingModel_PICKUP_AND_DELIVERY_LIFO
4662    r""" Deliveries must be performed in reverse order of pickups."""
4663    PICKUP_AND_DELIVERY_FIFO = _pywrapcp.RoutingModel_PICKUP_AND_DELIVERY_FIFO
4664    r""" Deliveries must be performed in the same order as pickups."""
4665
4666    def __init__(self, *args):
4667        _pywrapcp.RoutingModel_swiginit(self, _pywrapcp.new_RoutingModel(*args))
4668    __swig_destroy__ = _pywrapcp.delete_RoutingModel
4669
4670    def RegisterUnaryTransitVector(self, values):
4671        r""" Registers 'callback' and returns its index."""
4672        return _pywrapcp.RoutingModel_RegisterUnaryTransitVector(self, values)
4673
4674    def RegisterUnaryTransitCallback(self, callback):
4675        return _pywrapcp.RoutingModel_RegisterUnaryTransitCallback(self, callback)
4676
4677    def RegisterPositiveUnaryTransitCallback(self, callback):
4678        return _pywrapcp.RoutingModel_RegisterPositiveUnaryTransitCallback(self, callback)
4679
4680    def RegisterTransitMatrix(self, values):
4681        return _pywrapcp.RoutingModel_RegisterTransitMatrix(self, values)
4682
4683    def RegisterTransitCallback(self, callback):
4684        return _pywrapcp.RoutingModel_RegisterTransitCallback(self, callback)
4685
4686    def RegisterPositiveTransitCallback(self, callback):
4687        return _pywrapcp.RoutingModel_RegisterPositiveTransitCallback(self, callback)
4688
4689    def TransitCallback(self, callback_index):
4690        return _pywrapcp.RoutingModel_TransitCallback(self, callback_index)
4691
4692    def UnaryTransitCallbackOrNull(self, callback_index):
4693        return _pywrapcp.RoutingModel_UnaryTransitCallbackOrNull(self, callback_index)
4694
4695    def AddDimension(self, evaluator_index, slack_max, capacity, fix_start_cumul_to_zero, name):
4696        r"""
4697        Model creation
4698        Methods to add dimensions to routes; dimensions represent quantities
4699        accumulated at nodes along the routes. They represent quantities such as
4700        weights or volumes carried along the route, or distance or times.
4701        Quantities at a node are represented by "cumul" variables and the increase
4702        or decrease of quantities between nodes are represented by "transit"
4703        variables. These variables are linked as follows:
4704        if j == next(i), cumul(j) = cumul(i) + transit(i, j) + slack(i)
4705        where slack is a positive slack variable (can represent waiting times for
4706        a time dimension).
4707        Setting the value of fix_start_cumul_to_zero to true will force the
4708        "cumul" variable of the start node of all vehicles to be equal to 0.
4709        Creates a dimension where the transit variable is constrained to be
4710        equal to evaluator(i, next(i)); 'slack_max' is the upper bound of the
4711        slack variable and 'capacity' is the upper bound of the cumul variables.
4712        'name' is the name used to reference the dimension; this name is used to
4713        get cumul and transit variables from the routing model.
4714        Returns false if a dimension with the same name has already been created
4715        (and doesn't create the new dimension).
4716        Takes ownership of the callback 'evaluator'.
4717        """
4718        return _pywrapcp.RoutingModel_AddDimension(self, evaluator_index, slack_max, capacity, fix_start_cumul_to_zero, name)
4719
4720    def AddDimensionWithVehicleTransits(self, evaluator_indices, slack_max, capacity, fix_start_cumul_to_zero, name):
4721        return _pywrapcp.RoutingModel_AddDimensionWithVehicleTransits(self, evaluator_indices, slack_max, capacity, fix_start_cumul_to_zero, name)
4722
4723    def AddDimensionWithVehicleCapacity(self, evaluator_index, slack_max, vehicle_capacities, fix_start_cumul_to_zero, name):
4724        return _pywrapcp.RoutingModel_AddDimensionWithVehicleCapacity(self, evaluator_index, slack_max, vehicle_capacities, fix_start_cumul_to_zero, name)
4725
4726    def AddDimensionWithVehicleTransitAndCapacity(self, evaluator_indices, slack_max, vehicle_capacities, fix_start_cumul_to_zero, name):
4727        return _pywrapcp.RoutingModel_AddDimensionWithVehicleTransitAndCapacity(self, evaluator_indices, slack_max, vehicle_capacities, fix_start_cumul_to_zero, name)
4728
4729    def AddConstantDimensionWithSlack(self, value, capacity, slack_max, fix_start_cumul_to_zero, name):
4730        r"""
4731        Creates a dimension where the transit variable is constrained to be
4732        equal to 'value'; 'capacity' is the upper bound of the cumul variables.
4733        'name' is the name used to reference the dimension; this name is used to
4734        get cumul and transit variables from the routing model.
4735        Returns a pair consisting of an index to the registered unary transit
4736        callback and a bool denoting whether the dimension has been created.
4737        It is false if a dimension with the same name has already been created
4738        (and doesn't create the new dimension but still register a new callback).
4739        """
4740        return _pywrapcp.RoutingModel_AddConstantDimensionWithSlack(self, value, capacity, slack_max, fix_start_cumul_to_zero, name)
4741
4742    def AddConstantDimension(self, value, capacity, fix_start_cumul_to_zero, name):
4743        return _pywrapcp.RoutingModel_AddConstantDimension(self, value, capacity, fix_start_cumul_to_zero, name)
4744
4745    def AddVectorDimension(self, values, capacity, fix_start_cumul_to_zero, name):
4746        r"""
4747        Creates a dimension where the transit variable is constrained to be
4748        equal to 'values[i]' for node i; 'capacity' is the upper bound of
4749        the cumul variables. 'name' is the name used to reference the dimension;
4750        this name is used to get cumul and transit variables from the routing
4751        model.
4752        Returns a pair consisting of an index to the registered unary transit
4753        callback and a bool denoting whether the dimension has been created.
4754        It is false if a dimension with the same name has already been created
4755        (and doesn't create the new dimension but still register a new callback).
4756        """
4757        return _pywrapcp.RoutingModel_AddVectorDimension(self, values, capacity, fix_start_cumul_to_zero, name)
4758
4759    def AddMatrixDimension(self, values, capacity, fix_start_cumul_to_zero, name):
4760        r"""
4761        Creates a dimension where the transit variable is constrained to be
4762        equal to 'values[i][next(i)]' for node i; 'capacity' is the upper bound of
4763        the cumul variables. 'name' is the name used to reference the dimension;
4764        this name is used to get cumul and transit variables from the routing
4765        model.
4766        Returns a pair consisting of an index to the registered transit callback
4767        and a bool denoting whether the dimension has been created.
4768        It is false if a dimension with the same name has already been created
4769        (and doesn't create the new dimension but still register a new callback).
4770        """
4771        return _pywrapcp.RoutingModel_AddMatrixDimension(self, values, capacity, fix_start_cumul_to_zero, name)
4772
4773    def MakePathSpansAndTotalSlacks(self, dimension, spans, total_slacks):
4774        r"""
4775        For every vehicle of the routing model:
4776        - if total_slacks[vehicle] is not nullptr, constrains it to be the sum of
4777          slacks on that vehicle, that is,
4778          dimension->CumulVar(end) - dimension->CumulVar(start) -
4779          sum_{node in path of vehicle} dimension->FixedTransitVar(node).
4780        - if spans[vehicle] is not nullptr, constrains it to be
4781          dimension->CumulVar(end) - dimension->CumulVar(start)
4782        This does stronger propagation than a decomposition, and takes breaks into
4783        account.
4784        """
4785        return _pywrapcp.RoutingModel_MakePathSpansAndTotalSlacks(self, dimension, spans, total_slacks)
4786
4787    def GetAllDimensionNames(self):
4788        r""" Outputs the names of all dimensions added to the routing engine."""
4789        return _pywrapcp.RoutingModel_GetAllDimensionNames(self)
4790
4791    def GetDimensions(self):
4792        r""" Returns all dimensions of the model."""
4793        return _pywrapcp.RoutingModel_GetDimensions(self)
4794
4795    def GetDimensionsWithSoftOrSpanCosts(self):
4796        r""" Returns dimensions with soft or vehicle span costs."""
4797        return _pywrapcp.RoutingModel_GetDimensionsWithSoftOrSpanCosts(self)
4798
4799    def GetDimensionsWithGlobalCumulOptimizers(self):
4800        r""" Returns the dimensions which have [global|local]_dimension_optimizers_."""
4801        return _pywrapcp.RoutingModel_GetDimensionsWithGlobalCumulOptimizers(self)
4802
4803    def GetDimensionsWithLocalCumulOptimizers(self):
4804        return _pywrapcp.RoutingModel_GetDimensionsWithLocalCumulOptimizers(self)
4805
4806    def HasGlobalCumulOptimizer(self, dimension):
4807        r""" Returns whether the given dimension has global/local cumul optimizers."""
4808        return _pywrapcp.RoutingModel_HasGlobalCumulOptimizer(self, dimension)
4809
4810    def HasLocalCumulOptimizer(self, dimension):
4811        return _pywrapcp.RoutingModel_HasLocalCumulOptimizer(self, dimension)
4812
4813    def GetMutableGlobalCumulLPOptimizer(self, dimension):
4814        r"""
4815        Returns the global/local dimension cumul optimizer for a given dimension,
4816        or nullptr if there is none.
4817        """
4818        return _pywrapcp.RoutingModel_GetMutableGlobalCumulLPOptimizer(self, dimension)
4819
4820    def GetMutableGlobalCumulMPOptimizer(self, dimension):
4821        return _pywrapcp.RoutingModel_GetMutableGlobalCumulMPOptimizer(self, dimension)
4822
4823    def GetMutableLocalCumulLPOptimizer(self, dimension):
4824        return _pywrapcp.RoutingModel_GetMutableLocalCumulLPOptimizer(self, dimension)
4825
4826    def GetMutableLocalCumulMPOptimizer(self, dimension):
4827        return _pywrapcp.RoutingModel_GetMutableLocalCumulMPOptimizer(self, dimension)
4828
4829    def HasDimension(self, dimension_name):
4830        r""" Returns true if a dimension exists for a given dimension name."""
4831        return _pywrapcp.RoutingModel_HasDimension(self, dimension_name)
4832
4833    def GetDimensionOrDie(self, dimension_name):
4834        r""" Returns a dimension from its name. Dies if the dimension does not exist."""
4835        return _pywrapcp.RoutingModel_GetDimensionOrDie(self, dimension_name)
4836
4837    def GetMutableDimension(self, dimension_name):
4838        r"""
4839        Returns a dimension from its name. Returns nullptr if the dimension does
4840        not exist.
4841        """
4842        return _pywrapcp.RoutingModel_GetMutableDimension(self, dimension_name)
4843
4844    def SetPrimaryConstrainedDimension(self, dimension_name):
4845        r"""
4846        Set the given dimension as "primary constrained". As of August 2013, this
4847        is only used by ArcIsMoreConstrainedThanArc().
4848        "dimension" must be the name of an existing dimension, or be empty, in
4849        which case there will not be a primary dimension after this call.
4850        """
4851        return _pywrapcp.RoutingModel_SetPrimaryConstrainedDimension(self, dimension_name)
4852
4853    def GetPrimaryConstrainedDimension(self):
4854        r""" Get the primary constrained dimension, or an empty string if it is unset."""
4855        return _pywrapcp.RoutingModel_GetPrimaryConstrainedDimension(self)
4856
4857    def AddResourceGroup(self):
4858        r"""
4859        Adds a resource group to the routing model. Returns its index in
4860        resource_groups_.
4861        """
4862        return _pywrapcp.RoutingModel_AddResourceGroup(self)
4863
4864    def GetResourceGroups(self):
4865        return _pywrapcp.RoutingModel_GetResourceGroups(self)
4866
4867    def GetResourceGroup(self, rg_index):
4868        return _pywrapcp.RoutingModel_GetResourceGroup(self, rg_index)
4869
4870    def GetDimensionResourceGroupIndices(self, dimension):
4871        r"""
4872        Returns the indices of resource groups for this dimension. This method can
4873        only be called after the model has been closed.
4874        """
4875        return _pywrapcp.RoutingModel_GetDimensionResourceGroupIndices(self, dimension)
4876
4877    def GetDimensionResourceGroupIndex(self, dimension):
4878        r"""
4879        Returns the index of the resource group attached to the dimension.
4880        DCHECKS that there's exactly one resource group for this dimension.
4881        """
4882        return _pywrapcp.RoutingModel_GetDimensionResourceGroupIndex(self, dimension)
4883
4884    def AddDisjunction(self, *args):
4885        r"""
4886        Adds a disjunction constraint on the indices: exactly 'max_cardinality' of
4887        the indices are active. Start and end indices of any vehicle cannot be
4888        part of a disjunction.
4889
4890        If a penalty is given, at most 'max_cardinality' of the indices can be
4891        active, and if less are active, 'penalty' is payed per inactive index.
4892        This is equivalent to adding the constraint:
4893            p + Sum(i)active[i] == max_cardinality
4894        where p is an integer variable, and the following cost to the cost
4895        function:
4896            p * penalty.
4897        'penalty' must be positive to make the disjunction optional; a negative
4898        penalty will force 'max_cardinality' indices of the disjunction to be
4899        performed, and therefore p == 0.
4900        Note: passing a vector with a single index will model an optional index
4901        with a penalty cost if it is not visited.
4902        """
4903        return _pywrapcp.RoutingModel_AddDisjunction(self, *args)
4904
4905    def GetDisjunctionIndices(self, index):
4906        r""" Returns the indices of the disjunctions to which an index belongs."""
4907        return _pywrapcp.RoutingModel_GetDisjunctionIndices(self, index)
4908
4909    def GetDisjunctionPenalty(self, index):
4910        r""" Returns the penalty of the node disjunction of index 'index'."""
4911        return _pywrapcp.RoutingModel_GetDisjunctionPenalty(self, index)
4912
4913    def GetDisjunctionMaxCardinality(self, index):
4914        r"""
4915        Returns the maximum number of possible active nodes of the node
4916        disjunction of index 'index'.
4917        """
4918        return _pywrapcp.RoutingModel_GetDisjunctionMaxCardinality(self, index)
4919
4920    def GetNumberOfDisjunctions(self):
4921        r""" Returns the number of node disjunctions in the model."""
4922        return _pywrapcp.RoutingModel_GetNumberOfDisjunctions(self)
4923
4924    def HasMandatoryDisjunctions(self):
4925        r"""
4926        Returns true if the model contains mandatory disjunctions (ones with
4927        kNoPenalty as penalty).
4928        """
4929        return _pywrapcp.RoutingModel_HasMandatoryDisjunctions(self)
4930
4931    def HasMaxCardinalityConstrainedDisjunctions(self):
4932        r"""
4933        Returns true if the model contains at least one disjunction which is
4934        constrained by its max_cardinality.
4935        """
4936        return _pywrapcp.RoutingModel_HasMaxCardinalityConstrainedDisjunctions(self)
4937
4938    def GetPerfectBinaryDisjunctions(self):
4939        r"""
4940        Returns the list of all perfect binary disjunctions, as pairs of variable
4941        indices: a disjunction is "perfect" when its variables do not appear in
4942        any other disjunction. Each pair is sorted (lowest variable index first),
4943        and the output vector is also sorted (lowest pairs first).
4944        """
4945        return _pywrapcp.RoutingModel_GetPerfectBinaryDisjunctions(self)
4946
4947    def IgnoreDisjunctionsAlreadyForcedToZero(self):
4948        r"""
4949        SPECIAL: Makes the solver ignore all the disjunctions whose active
4950        variables are all trivially zero (i.e. Max() == 0), by setting their
4951        max_cardinality to 0.
4952        This can be useful when using the BaseBinaryDisjunctionNeighborhood
4953        operators, in the context of arc-based routing.
4954        """
4955        return _pywrapcp.RoutingModel_IgnoreDisjunctionsAlreadyForcedToZero(self)
4956
4957    def AddSoftSameVehicleConstraint(self, indices, cost):
4958        r"""
4959        Adds a soft constraint to force a set of variable indices to be on the
4960        same vehicle. If all nodes are not on the same vehicle, each extra vehicle
4961        used adds 'cost' to the cost function.
4962        """
4963        return _pywrapcp.RoutingModel_AddSoftSameVehicleConstraint(self, indices, cost)
4964
4965    def SetAllowedVehiclesForIndex(self, vehicles, index):
4966        r"""
4967        Sets the vehicles which can visit a given node. If the node is in a
4968        disjunction, this will not prevent it from being unperformed.
4969        Specifying an empty vector of vehicles has no effect (all vehicles
4970        will be allowed to visit the node).
4971        """
4972        return _pywrapcp.RoutingModel_SetAllowedVehiclesForIndex(self, vehicles, index)
4973
4974    def IsVehicleAllowedForIndex(self, vehicle, index):
4975        r""" Returns true if a vehicle is allowed to visit a given node."""
4976        return _pywrapcp.RoutingModel_IsVehicleAllowedForIndex(self, vehicle, index)
4977
4978    def AddPickupAndDelivery(self, pickup, delivery):
4979        r"""
4980        Notifies that index1 and index2 form a pair of nodes which should belong
4981        to the same route. This methods helps the search find better solutions,
4982        especially in the local search phase.
4983        It should be called each time you have an equality constraint linking
4984        the vehicle variables of two node (including for instance pickup and
4985        delivery problems):
4986            Solver* const solver = routing.solver();
4987            int64_t index1 = manager.NodeToIndex(node1);
4988            int64_t index2 = manager.NodeToIndex(node2);
4989            solver->AddConstraint(solver->MakeEquality(
4990                routing.VehicleVar(index1),
4991                routing.VehicleVar(index2)));
4992            routing.AddPickupAndDelivery(index1, index2);
4993        """
4994        return _pywrapcp.RoutingModel_AddPickupAndDelivery(self, pickup, delivery)
4995
4996    def AddPickupAndDeliverySets(self, pickup_disjunction, delivery_disjunction):
4997        r"""
4998        Same as AddPickupAndDelivery but notifying that the performed node from
4999        the disjunction of index 'pickup_disjunction' is on the same route as the
5000        performed node from the disjunction of index 'delivery_disjunction'.
5001        """
5002        return _pywrapcp.RoutingModel_AddPickupAndDeliverySets(self, pickup_disjunction, delivery_disjunction)
5003
5004    def GetPickupIndexPairs(self, node_index):
5005        r"""
5006        Returns pairs for which the node is a pickup; the first element of each
5007        pair is the index in the pickup and delivery pairs list in which the
5008        pickup appears, the second element is its index in the pickups list.
5009        """
5010        return _pywrapcp.RoutingModel_GetPickupIndexPairs(self, node_index)
5011
5012    def GetDeliveryIndexPairs(self, node_index):
5013        r""" Same as above for deliveries."""
5014        return _pywrapcp.RoutingModel_GetDeliveryIndexPairs(self, node_index)
5015
5016    def SetPickupAndDeliveryPolicyOfAllVehicles(self, policy):
5017        r"""
5018        Sets the Pickup and delivery policy of all vehicles. It is equivalent to
5019        calling SetPickupAndDeliveryPolicyOfVehicle on all vehicles.
5020        """
5021        return _pywrapcp.RoutingModel_SetPickupAndDeliveryPolicyOfAllVehicles(self, policy)
5022
5023    def SetPickupAndDeliveryPolicyOfVehicle(self, policy, vehicle):
5024        return _pywrapcp.RoutingModel_SetPickupAndDeliveryPolicyOfVehicle(self, policy, vehicle)
5025
5026    def GetPickupAndDeliveryPolicyOfVehicle(self, vehicle):
5027        return _pywrapcp.RoutingModel_GetPickupAndDeliveryPolicyOfVehicle(self, vehicle)
5028
5029    def GetNumOfSingletonNodes(self):
5030        r"""
5031        Returns the number of non-start/end nodes which do not appear in a
5032        pickup/delivery pair.
5033        """
5034        return _pywrapcp.RoutingModel_GetNumOfSingletonNodes(self)
5035    TYPE_ADDED_TO_VEHICLE = _pywrapcp.RoutingModel_TYPE_ADDED_TO_VEHICLE
5036    r""" When visited, the number of types 'T' on the vehicle increases by one."""
5037    ADDED_TYPE_REMOVED_FROM_VEHICLE = _pywrapcp.RoutingModel_ADDED_TYPE_REMOVED_FROM_VEHICLE
5038    r"""
5039    When visited, one instance of type 'T' previously added to the route
5040    (TYPE_ADDED_TO_VEHICLE), if any, is removed from the vehicle.
5041    If the type was not previously added to the route or all added instances
5042    have already been removed, this visit has no effect on the types.
5043    """
5044    TYPE_ON_VEHICLE_UP_TO_VISIT = _pywrapcp.RoutingModel_TYPE_ON_VEHICLE_UP_TO_VISIT
5045    r"""
5046    With the following policy, the visit enforces that type 'T' is
5047    considered on the route from its start until this node is visited.
5048    """
5049    TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED = _pywrapcp.RoutingModel_TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED
5050    r"""
5051    The visit doesn't have an impact on the number of types 'T' on the
5052    route, as it's (virtually) added and removed directly.
5053    This policy can be used for visits which are part of an incompatibility
5054    or requirement set without affecting the type count on the route.
5055    """
5056
5057    def SetVisitType(self, index, type, type_policy):
5058        return _pywrapcp.RoutingModel_SetVisitType(self, index, type, type_policy)
5059
5060    def GetVisitType(self, index):
5061        return _pywrapcp.RoutingModel_GetVisitType(self, index)
5062
5063    def GetSingleNodesOfType(self, type):
5064        return _pywrapcp.RoutingModel_GetSingleNodesOfType(self, type)
5065
5066    def GetPairIndicesOfType(self, type):
5067        return _pywrapcp.RoutingModel_GetPairIndicesOfType(self, type)
5068
5069    def GetVisitTypePolicy(self, index):
5070        return _pywrapcp.RoutingModel_GetVisitTypePolicy(self, index)
5071
5072    def CloseVisitTypes(self):
5073        r"""
5074        This function should be called once all node visit types have been set and
5075        prior to adding any incompatibilities/requirements.
5076        "close" types.
5077        """
5078        return _pywrapcp.RoutingModel_CloseVisitTypes(self)
5079
5080    def GetNumberOfVisitTypes(self):
5081        return _pywrapcp.RoutingModel_GetNumberOfVisitTypes(self)
5082
5083    def AddHardTypeIncompatibility(self, type1, type2):
5084        r"""
5085        Incompatibilities:
5086        Two nodes with "hard" incompatible types cannot share the same route at
5087        all, while with a "temporal" incompatibility they can't be on the same
5088        route at the same time.
5089        """
5090        return _pywrapcp.RoutingModel_AddHardTypeIncompatibility(self, type1, type2)
5091
5092    def AddTemporalTypeIncompatibility(self, type1, type2):
5093        return _pywrapcp.RoutingModel_AddTemporalTypeIncompatibility(self, type1, type2)
5094
5095    def GetHardTypeIncompatibilitiesOfType(self, type):
5096        r""" Returns visit types incompatible with a given type."""
5097        return _pywrapcp.RoutingModel_GetHardTypeIncompatibilitiesOfType(self, type)
5098
5099    def GetTemporalTypeIncompatibilitiesOfType(self, type):
5100        return _pywrapcp.RoutingModel_GetTemporalTypeIncompatibilitiesOfType(self, type)
5101
5102    def HasHardTypeIncompatibilities(self):
5103        r"""
5104        Returns true iff any hard (resp. temporal) type incompatibilities have
5105        been added to the model.
5106        """
5107        return _pywrapcp.RoutingModel_HasHardTypeIncompatibilities(self)
5108
5109    def HasTemporalTypeIncompatibilities(self):
5110        return _pywrapcp.RoutingModel_HasTemporalTypeIncompatibilities(self)
5111
5112    def AddSameVehicleRequiredTypeAlternatives(self, dependent_type, required_type_alternatives):
5113        r"""
5114        Requirements:
5115        NOTE: As of 2019-04, cycles in the requirement graph are not supported,
5116        and lead to the dependent nodes being skipped if possible (otherwise
5117        the model is considered infeasible).
5118        The following functions specify that "dependent_type" requires at least
5119        one of the types in "required_type_alternatives".
5120
5121        For same-vehicle requirements, a node of dependent type type_D requires at
5122        least one node of type type_R among the required alternatives on the same
5123        route.
5124        """
5125        return _pywrapcp.RoutingModel_AddSameVehicleRequiredTypeAlternatives(self, dependent_type, required_type_alternatives)
5126
5127    def AddRequiredTypeAlternativesWhenAddingType(self, dependent_type, required_type_alternatives):
5128        r"""
5129        If type_D depends on type_R when adding type_D, any node_D of type_D and
5130        VisitTypePolicy TYPE_ADDED_TO_VEHICLE or
5131        TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED requires at least one type_R on its
5132        vehicle at the time node_D is visited.
5133        """
5134        return _pywrapcp.RoutingModel_AddRequiredTypeAlternativesWhenAddingType(self, dependent_type, required_type_alternatives)
5135
5136    def AddRequiredTypeAlternativesWhenRemovingType(self, dependent_type, required_type_alternatives):
5137        r"""
5138        The following requirements apply when visiting dependent nodes that remove
5139        their type from the route, i.e. type_R must be on the vehicle when type_D
5140        of VisitTypePolicy ADDED_TYPE_REMOVED_FROM_VEHICLE,
5141        TYPE_ON_VEHICLE_UP_TO_VISIT or TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED is
5142        visited.
5143        """
5144        return _pywrapcp.RoutingModel_AddRequiredTypeAlternativesWhenRemovingType(self, dependent_type, required_type_alternatives)
5145
5146    def GetSameVehicleRequiredTypeAlternativesOfType(self, type):
5147        r"""
5148        Returns the set of same-vehicle requirement alternatives for the given
5149        type.
5150        """
5151        return _pywrapcp.RoutingModel_GetSameVehicleRequiredTypeAlternativesOfType(self, type)
5152
5153    def GetRequiredTypeAlternativesWhenAddingType(self, type):
5154        r""" Returns the set of requirement alternatives when adding the given type."""
5155        return _pywrapcp.RoutingModel_GetRequiredTypeAlternativesWhenAddingType(self, type)
5156
5157    def GetRequiredTypeAlternativesWhenRemovingType(self, type):
5158        r""" Returns the set of requirement alternatives when removing the given type."""
5159        return _pywrapcp.RoutingModel_GetRequiredTypeAlternativesWhenRemovingType(self, type)
5160
5161    def HasSameVehicleTypeRequirements(self):
5162        r"""
5163        Returns true iff any same-route (resp. temporal) type requirements have
5164        been added to the model.
5165        """
5166        return _pywrapcp.RoutingModel_HasSameVehicleTypeRequirements(self)
5167
5168    def HasTemporalTypeRequirements(self):
5169        return _pywrapcp.RoutingModel_HasTemporalTypeRequirements(self)
5170
5171    def HasTypeRegulations(self):
5172        r"""
5173        Returns true iff the model has any incompatibilities or requirements set
5174        on node types.
5175        """
5176        return _pywrapcp.RoutingModel_HasTypeRegulations(self)
5177
5178    def UnperformedPenalty(self, var_index):
5179        r"""
5180        Get the "unperformed" penalty of a node. This is only well defined if the
5181        node is only part of a single Disjunction, and that disjunction has a
5182        penalty. For forced active nodes returns max int64_t. In all other cases,
5183        this returns 0.
5184        """
5185        return _pywrapcp.RoutingModel_UnperformedPenalty(self, var_index)
5186
5187    def UnperformedPenaltyOrValue(self, default_value, var_index):
5188        r"""
5189        Same as above except that it returns default_value instead of 0 when
5190        penalty is not well defined (default value is passed as first argument to
5191        simplify the usage of the method in a callback).
5192        """
5193        return _pywrapcp.RoutingModel_UnperformedPenaltyOrValue(self, default_value, var_index)
5194
5195    def GetDepot(self):
5196        r"""
5197        Returns the variable index of the first starting or ending node of all
5198        routes. If all routes start  and end at the same node (single depot), this
5199        is the node returned.
5200        """
5201        return _pywrapcp.RoutingModel_GetDepot(self)
5202
5203    def SetMaximumNumberOfActiveVehicles(self, max_active_vehicles):
5204        r"""
5205        Constrains the maximum number of active vehicles, aka the number of
5206        vehicles which do not have an empty route. For instance, this can be used
5207        to limit the number of routes in the case where there are fewer drivers
5208        than vehicles and that the fleet of vehicle is heterogeneous.
5209        """
5210        return _pywrapcp.RoutingModel_SetMaximumNumberOfActiveVehicles(self, max_active_vehicles)
5211
5212    def GetMaximumNumberOfActiveVehicles(self):
5213        r""" Returns the maximum number of active vehicles."""
5214        return _pywrapcp.RoutingModel_GetMaximumNumberOfActiveVehicles(self)
5215
5216    def SetArcCostEvaluatorOfAllVehicles(self, evaluator_index):
5217        r"""
5218        Sets the cost function of the model such that the cost of a segment of a
5219        route between node 'from' and 'to' is evaluator(from, to), whatever the
5220        route or vehicle performing the route.
5221        """
5222        return _pywrapcp.RoutingModel_SetArcCostEvaluatorOfAllVehicles(self, evaluator_index)
5223
5224    def SetArcCostEvaluatorOfVehicle(self, evaluator_index, vehicle):
5225        r""" Sets the cost function for a given vehicle route."""
5226        return _pywrapcp.RoutingModel_SetArcCostEvaluatorOfVehicle(self, evaluator_index, vehicle)
5227
5228    def SetFixedCostOfAllVehicles(self, cost):
5229        r"""
5230        Sets the fixed cost of all vehicle routes. It is equivalent to calling
5231        SetFixedCostOfVehicle on all vehicle routes.
5232        """
5233        return _pywrapcp.RoutingModel_SetFixedCostOfAllVehicles(self, cost)
5234
5235    def SetFixedCostOfVehicle(self, cost, vehicle):
5236        r""" Sets the fixed cost of one vehicle route."""
5237        return _pywrapcp.RoutingModel_SetFixedCostOfVehicle(self, cost, vehicle)
5238
5239    def GetFixedCostOfVehicle(self, vehicle):
5240        r"""
5241        Returns the route fixed cost taken into account if the route of the
5242        vehicle is not empty, aka there's at least one node on the route other
5243        than the first and last nodes.
5244        """
5245        return _pywrapcp.RoutingModel_GetFixedCostOfVehicle(self, vehicle)
5246
5247    def SetAmortizedCostFactorsOfAllVehicles(self, linear_cost_factor, quadratic_cost_factor):
5248        r"""
5249        The following methods set the linear and quadratic cost factors of
5250        vehicles (must be positive values). The default value of these parameters
5251        is zero for all vehicles.
5252
5253        When set, the cost_ of the model will contain terms aiming at reducing the
5254        number of vehicles used in the model, by adding the following to the
5255        objective for every vehicle v:
5256        INDICATOR(v used in the model) *
5257          [linear_cost_factor_of_vehicle_[v]
5258           - quadratic_cost_factor_of_vehicle_[v]*(square of length of route v)]
5259        i.e. for every used vehicle, we add the linear factor as fixed cost, and
5260        subtract the square of the route length multiplied by the quadratic
5261        factor. This second term aims at making the routes as dense as possible.
5262
5263        Sets the linear and quadratic cost factor of all vehicles.
5264        """
5265        return _pywrapcp.RoutingModel_SetAmortizedCostFactorsOfAllVehicles(self, linear_cost_factor, quadratic_cost_factor)
5266
5267    def SetAmortizedCostFactorsOfVehicle(self, linear_cost_factor, quadratic_cost_factor, vehicle):
5268        r""" Sets the linear and quadratic cost factor of the given vehicle."""
5269        return _pywrapcp.RoutingModel_SetAmortizedCostFactorsOfVehicle(self, linear_cost_factor, quadratic_cost_factor, vehicle)
5270
5271    def GetAmortizedLinearCostFactorOfVehicles(self):
5272        return _pywrapcp.RoutingModel_GetAmortizedLinearCostFactorOfVehicles(self)
5273
5274    def GetAmortizedQuadraticCostFactorOfVehicles(self):
5275        return _pywrapcp.RoutingModel_GetAmortizedQuadraticCostFactorOfVehicles(self)
5276
5277    def SetVehicleUsedWhenEmpty(self, is_used, vehicle):
5278        return _pywrapcp.RoutingModel_SetVehicleUsedWhenEmpty(self, is_used, vehicle)
5279
5280    def IsVehicleUsedWhenEmpty(self, vehicle):
5281        return _pywrapcp.RoutingModel_IsVehicleUsedWhenEmpty(self, vehicle)
5282
5283    def SetFirstSolutionEvaluator(self, evaluator):
5284        r"""
5285        Gets/sets the evaluator used during the search. Only relevant when
5286        RoutingSearchParameters.first_solution_strategy = EVALUATOR_STRATEGY.
5287        Takes ownership of evaluator.
5288        """
5289        return _pywrapcp.RoutingModel_SetFirstSolutionEvaluator(self, evaluator)
5290
5291    def AddLocalSearchOperator(self, ls_operator):
5292        r"""
5293        Adds a local search operator to the set of operators used to solve the
5294        vehicle routing problem.
5295        """
5296        return _pywrapcp.RoutingModel_AddLocalSearchOperator(self, ls_operator)
5297
5298    def AddSearchMonitor(self, monitor):
5299        r""" Adds a search monitor to the search used to solve the routing model."""
5300        return _pywrapcp.RoutingModel_AddSearchMonitor(self, monitor)
5301
5302    def AddAtSolutionCallback(self, callback):
5303        r"""
5304        Adds a callback called each time a solution is found during the search.
5305        This is a shortcut to creating a monitor to call the callback on
5306        AtSolution() and adding it with AddSearchMonitor.
5307        """
5308        return _pywrapcp.RoutingModel_AddAtSolutionCallback(self, callback)
5309
5310    def AddVariableMinimizedByFinalizer(self, var):
5311        r"""
5312        Adds a variable to minimize in the solution finalizer. The solution
5313        finalizer is called each time a solution is found during the search and
5314        allows to instantiate secondary variables (such as dimension cumul
5315        variables).
5316        """
5317        return _pywrapcp.RoutingModel_AddVariableMinimizedByFinalizer(self, var)
5318
5319    def AddVariableMaximizedByFinalizer(self, var):
5320        r"""
5321        Adds a variable to maximize in the solution finalizer (see above for
5322        information on the solution finalizer).
5323        """
5324        return _pywrapcp.RoutingModel_AddVariableMaximizedByFinalizer(self, var)
5325
5326    def AddWeightedVariableMinimizedByFinalizer(self, var, cost):
5327        r"""
5328        Adds a variable to minimize in the solution finalizer, with a weighted
5329        priority: the higher the more priority it has.
5330        """
5331        return _pywrapcp.RoutingModel_AddWeightedVariableMinimizedByFinalizer(self, var, cost)
5332
5333    def AddWeightedVariableMaximizedByFinalizer(self, var, cost):
5334        r"""
5335        Adds a variable to maximize in the solution finalizer, with a weighted
5336        priority: the higher the more priority it has.
5337        """
5338        return _pywrapcp.RoutingModel_AddWeightedVariableMaximizedByFinalizer(self, var, cost)
5339
5340    def AddVariableTargetToFinalizer(self, var, target):
5341        r"""
5342        Add a variable to set the closest possible to the target value in the
5343        solution finalizer.
5344        """
5345        return _pywrapcp.RoutingModel_AddVariableTargetToFinalizer(self, var, target)
5346
5347    def AddWeightedVariableTargetToFinalizer(self, var, target, cost):
5348        r"""
5349        Same as above with a weighted priority: the higher the cost, the more
5350        priority it has to be set close to the target value.
5351        """
5352        return _pywrapcp.RoutingModel_AddWeightedVariableTargetToFinalizer(self, var, target, cost)
5353
5354    def CloseModel(self):
5355        r"""
5356        Closes the current routing model; after this method is called, no
5357        modification to the model can be done, but RoutesToAssignment becomes
5358        available. Note that CloseModel() is automatically called by Solve() and
5359        other methods that produce solution.
5360        This is equivalent to calling
5361        CloseModelWithParameters(DefaultRoutingSearchParameters()).
5362        """
5363        return _pywrapcp.RoutingModel_CloseModel(self)
5364
5365    def CloseModelWithParameters(self, search_parameters):
5366        r"""
5367        Same as above taking search parameters (as of 10/2015 some the parameters
5368        have to be set when closing the model).
5369        """
5370        return _pywrapcp.RoutingModel_CloseModelWithParameters(self, search_parameters)
5371
5372    def Solve(self, assignment=None):
5373        r"""
5374        Solves the current routing model; closes the current model.
5375        This is equivalent to calling
5376        SolveWithParameters(DefaultRoutingSearchParameters())
5377        or
5378        SolveFromAssignmentWithParameters(assignment,
5379                                          DefaultRoutingSearchParameters()).
5380        """
5381        return _pywrapcp.RoutingModel_Solve(self, assignment)
5382
5383    def SolveWithParameters(self, search_parameters, solutions=None):
5384        r"""
5385        Solves the current routing model with the given parameters. If 'solutions'
5386        is specified, it will contain the k best solutions found during the search
5387        (from worst to best, including the one returned by this method), where k
5388        corresponds to the 'number_of_solutions_to_collect' in
5389        'search_parameters'. Note that the Assignment returned by the method and
5390        the ones in solutions are owned by the underlying solver and should not be
5391        deleted.
5392        """
5393        return _pywrapcp.RoutingModel_SolveWithParameters(self, search_parameters, solutions)
5394
5395    def SolveFromAssignmentWithParameters(self, assignment, search_parameters, solutions=None):
5396        r"""
5397        Same as above, except that if assignment is not null, it will be used as
5398        the initial solution.
5399        """
5400        return _pywrapcp.RoutingModel_SolveFromAssignmentWithParameters(self, assignment, search_parameters, solutions)
5401
5402    def SolveFromAssignmentsWithParameters(self, assignments, search_parameters, solutions=None):
5403        r"""
5404        Same as above but will try all assignments in order as first solutions
5405        until one succeeds.
5406        """
5407        return _pywrapcp.RoutingModel_SolveFromAssignmentsWithParameters(self, assignments, search_parameters, solutions)
5408
5409    def SetAssignmentFromOtherModelAssignment(self, target_assignment, source_model, source_assignment):
5410        r"""
5411        Given a "source_model" and its "source_assignment", resets
5412        "target_assignment" with the IntVar variables (nexts_, and vehicle_vars_
5413        if costs aren't homogeneous across vehicles) of "this" model, with the
5414        values set according to those in "other_assignment".
5415        The objective_element of target_assignment is set to this->cost_.
5416        """
5417        return _pywrapcp.RoutingModel_SetAssignmentFromOtherModelAssignment(self, target_assignment, source_model, source_assignment)
5418
5419    def ComputeLowerBound(self):
5420        r"""
5421        Computes a lower bound to the routing problem solving a linear assignment
5422        problem. The routing model must be closed before calling this method.
5423        Note that problems with node disjunction constraints (including optional
5424        nodes) and non-homogenous costs are not supported (the method returns 0 in
5425        these cases).
5426        """
5427        return _pywrapcp.RoutingModel_ComputeLowerBound(self)
5428
5429    def status(self):
5430        r""" Returns the current status of the routing model."""
5431        return _pywrapcp.RoutingModel_status(self)
5432
5433    def enable_deep_serialization(self):
5434        r""" Returns the value of the internal enable_deep_serialization_ parameter."""
5435        return _pywrapcp.RoutingModel_enable_deep_serialization(self)
5436
5437    def ApplyLocks(self, locks):
5438        r"""
5439        Applies a lock chain to the next search. 'locks' represents an ordered
5440        vector of nodes representing a partial route which will be fixed during
5441        the next search; it will constrain next variables such that:
5442        next[locks[i]] == locks[i+1].
5443
5444        Returns the next variable at the end of the locked chain; this variable is
5445        not locked. An assignment containing the locks can be obtained by calling
5446        PreAssignment().
5447        """
5448        return _pywrapcp.RoutingModel_ApplyLocks(self, locks)
5449
5450    def ApplyLocksToAllVehicles(self, locks, close_routes):
5451        r"""
5452        Applies lock chains to all vehicles to the next search, such that locks[p]
5453        is the lock chain for route p. Returns false if the locks do not contain
5454        valid routes; expects that the routes do not contain the depots,
5455        i.e. there are empty vectors in place of empty routes.
5456        If close_routes is set to true, adds the end nodes to the route of each
5457        vehicle and deactivates other nodes.
5458        An assignment containing the locks can be obtained by calling
5459        PreAssignment().
5460        """
5461        return _pywrapcp.RoutingModel_ApplyLocksToAllVehicles(self, locks, close_routes)
5462
5463    def PreAssignment(self):
5464        r"""
5465        Returns an assignment used to fix some of the variables of the problem.
5466        In practice, this assignment locks partial routes of the problem. This
5467        can be used in the context of locking the parts of the routes which have
5468        already been driven in online routing problems.
5469        """
5470        return _pywrapcp.RoutingModel_PreAssignment(self)
5471
5472    def MutablePreAssignment(self):
5473        return _pywrapcp.RoutingModel_MutablePreAssignment(self)
5474
5475    def WriteAssignment(self, file_name):
5476        r"""
5477        Writes the current solution to a file containing an AssignmentProto.
5478        Returns false if the file cannot be opened or if there is no current
5479        solution.
5480        """
5481        return _pywrapcp.RoutingModel_WriteAssignment(self, file_name)
5482
5483    def ReadAssignment(self, file_name):
5484        r"""
5485        Reads an assignment from a file and returns the current solution.
5486        Returns nullptr if the file cannot be opened or if the assignment is not
5487        valid.
5488        """
5489        return _pywrapcp.RoutingModel_ReadAssignment(self, file_name)
5490
5491    def RestoreAssignment(self, solution):
5492        r"""
5493        Restores an assignment as a solution in the routing model and returns the
5494        new solution. Returns nullptr if the assignment is not valid.
5495        """
5496        return _pywrapcp.RoutingModel_RestoreAssignment(self, solution)
5497
5498    def ReadAssignmentFromRoutes(self, routes, ignore_inactive_indices):
5499        r"""
5500        Restores the routes as the current solution. Returns nullptr if the
5501        solution cannot be restored (routes do not contain a valid solution). Note
5502        that calling this method will run the solver to assign values to the
5503        dimension variables; this may take considerable amount of time, especially
5504        when using dimensions with slack.
5505        """
5506        return _pywrapcp.RoutingModel_ReadAssignmentFromRoutes(self, routes, ignore_inactive_indices)
5507
5508    def RoutesToAssignment(self, routes, ignore_inactive_indices, close_routes, assignment):
5509        r"""
5510        Fills an assignment from a specification of the routes of the
5511        vehicles. The routes are specified as lists of variable indices that
5512        appear on the routes of the vehicles. The indices of the outer vector in
5513        'routes' correspond to vehicles IDs, the inner vector contains the
5514        variable indices on the routes for the given vehicle. The inner vectors
5515        must not contain the start and end indices, as these are determined by the
5516        routing model.  Sets the value of NextVars in the assignment, adding the
5517        variables to the assignment if necessary. The method does not touch other
5518        variables in the assignment. The method can only be called after the model
5519        is closed.  With ignore_inactive_indices set to false, this method will
5520        fail (return nullptr) in case some of the route contain indices that are
5521        deactivated in the model; when set to true, these indices will be
5522        skipped.  Returns true if routes were successfully
5523        loaded. However, such assignment still might not be a valid
5524        solution to the routing problem due to more complex constraints;
5525        it is advisible to call solver()->CheckSolution() afterwards.
5526        """
5527        return _pywrapcp.RoutingModel_RoutesToAssignment(self, routes, ignore_inactive_indices, close_routes, assignment)
5528
5529    def AssignmentToRoutes(self, assignment, routes):
5530        r"""
5531        Converts the solution in the given assignment to routes for all vehicles.
5532        Expects that assignment contains a valid solution (i.e. routes for all
5533        vehicles end with an end index for that vehicle).
5534        """
5535        return _pywrapcp.RoutingModel_AssignmentToRoutes(self, assignment, routes)
5536
5537    def CompactAssignment(self, assignment):
5538        r"""
5539        Converts the solution in the given assignment to routes for all vehicles.
5540        If the returned vector is route_indices, route_indices[i][j] is the index
5541        for jth location visited on route i. Note that contrary to
5542        AssignmentToRoutes, the vectors do include start and end locations.
5543        Returns a compacted version of the given assignment, in which all vehicles
5544        with id lower or equal to some N have non-empty routes, and all vehicles
5545        with id greater than N have empty routes. Does not take ownership of the
5546        returned object.
5547        If found, the cost of the compact assignment is the same as in the
5548        original assignment and it preserves the values of 'active' variables.
5549        Returns nullptr if a compact assignment was not found.
5550        This method only works in homogenous mode, and it only swaps equivalent
5551        vehicles (vehicles with the same start and end nodes). When creating the
5552        compact assignment, the empty plan is replaced by the route assigned to
5553        the compatible vehicle with the highest id. Note that with more complex
5554        constraints on vehicle variables, this method might fail even if a compact
5555        solution exists.
5556        This method changes the vehicle and dimension variables as necessary.
5557        While compacting the solution, only basic checks on vehicle variables are
5558        performed; if one of these checks fails no attempts to repair it are made
5559        (instead, the method returns nullptr).
5560        """
5561        return _pywrapcp.RoutingModel_CompactAssignment(self, assignment)
5562
5563    def CompactAndCheckAssignment(self, assignment):
5564        r"""
5565        Same as CompactAssignment() but also checks the validity of the final
5566        compact solution; if it is not valid, no attempts to repair it are made
5567        (instead, the method returns nullptr).
5568        """
5569        return _pywrapcp.RoutingModel_CompactAndCheckAssignment(self, assignment)
5570
5571    def AddToAssignment(self, var):
5572        r""" Adds an extra variable to the vehicle routing assignment."""
5573        return _pywrapcp.RoutingModel_AddToAssignment(self, var)
5574
5575    def AddIntervalToAssignment(self, interval):
5576        return _pywrapcp.RoutingModel_AddIntervalToAssignment(self, interval)
5577
5578    def PackCumulsOfOptimizerDimensionsFromAssignment(self, original_assignment, duration_limit, time_limit_was_reached=None):
5579        r"""
5580        For every dimension in the model with an optimizer in
5581        local/global_dimension_optimizers_, this method tries to pack the cumul
5582        values of the dimension, such that:
5583        - The cumul costs (span costs, soft lower and upper bound costs, etc) are
5584          minimized.
5585        - The cumuls of the ends of the routes are minimized for this given
5586          minimal cumul cost.
5587        - Given these minimal end cumuls, the route start cumuls are maximized.
5588        Returns the assignment resulting from allocating these packed cumuls with
5589        the solver, and nullptr if these cumuls could not be set by the solver.
5590        """
5591        return _pywrapcp.RoutingModel_PackCumulsOfOptimizerDimensionsFromAssignment(self, original_assignment, duration_limit, time_limit_was_reached)
5592
5593    def GetOrCreateNodeNeighborsByCostClass(self, num_neighbors):
5594        r"""
5595        Returns num_neighbors neighbors of all nodes for every cost class. The
5596        result is cached and is computed once.
5597        """
5598        return _pywrapcp.RoutingModel_GetOrCreateNodeNeighborsByCostClass(self, num_neighbors)
5599
5600    def AddLocalSearchFilter(self, filter):
5601        r"""
5602        Adds a custom local search filter to the list of filters used to speed up
5603        local search by pruning unfeasible variable assignments.
5604        Calling this method after the routing model has been closed (CloseModel()
5605        or Solve() has been called) has no effect.
5606        The routing model does not take ownership of the filter.
5607        """
5608        return _pywrapcp.RoutingModel_AddLocalSearchFilter(self, filter)
5609
5610    def Start(self, vehicle):
5611        r"""
5612        Model inspection.
5613        Returns the variable index of the starting node of a vehicle route.
5614        """
5615        return _pywrapcp.RoutingModel_Start(self, vehicle)
5616
5617    def End(self, vehicle):
5618        r""" Returns the variable index of the ending node of a vehicle route."""
5619        return _pywrapcp.RoutingModel_End(self, vehicle)
5620
5621    def IsStart(self, index):
5622        r""" Returns true if 'index' represents the first node of a route."""
5623        return _pywrapcp.RoutingModel_IsStart(self, index)
5624
5625    def IsEnd(self, index):
5626        r""" Returns true if 'index' represents the last node of a route."""
5627        return _pywrapcp.RoutingModel_IsEnd(self, index)
5628
5629    def VehicleIndex(self, index):
5630        r"""
5631        Returns the vehicle of the given start/end index, and -1 if the given
5632        index is not a vehicle start/end.
5633        """
5634        return _pywrapcp.RoutingModel_VehicleIndex(self, index)
5635
5636    def Next(self, assignment, index):
5637        r"""
5638        Assignment inspection
5639        Returns the variable index of the node directly after the node
5640        corresponding to 'index' in 'assignment'.
5641        """
5642        return _pywrapcp.RoutingModel_Next(self, assignment, index)
5643
5644    def IsVehicleUsed(self, assignment, vehicle):
5645        r""" Returns true if the route of 'vehicle' is non empty in 'assignment'."""
5646        return _pywrapcp.RoutingModel_IsVehicleUsed(self, assignment, vehicle)
5647
5648    def NextVar(self, index):
5649        r"""
5650        Returns the next variable of the node corresponding to index. Note that
5651        NextVar(index) == index is equivalent to ActiveVar(index) == 0.
5652        """
5653        return _pywrapcp.RoutingModel_NextVar(self, index)
5654
5655    def ActiveVar(self, index):
5656        r""" Returns the active variable of the node corresponding to index."""
5657        return _pywrapcp.RoutingModel_ActiveVar(self, index)
5658
5659    def ActiveVehicleVar(self, vehicle):
5660        r"""
5661        Returns the active variable of the vehicle. It will be equal to 1 iff the
5662        route of the vehicle is not empty, 0 otherwise.
5663        """
5664        return _pywrapcp.RoutingModel_ActiveVehicleVar(self, vehicle)
5665
5666    def VehicleRouteConsideredVar(self, vehicle):
5667        r"""
5668        Returns the variable specifying whether or not the given vehicle route is
5669        considered for costs and constraints. It will be equal to 1 iff the route
5670        of the vehicle is not empty OR vehicle_used_when_empty_[vehicle] is true.
5671        """
5672        return _pywrapcp.RoutingModel_VehicleRouteConsideredVar(self, vehicle)
5673
5674    def VehicleVar(self, index):
5675        r"""
5676        Returns the vehicle variable of the node corresponding to index. Note that
5677        VehicleVar(index) == -1 is equivalent to ActiveVar(index) == 0.
5678        """
5679        return _pywrapcp.RoutingModel_VehicleVar(self, index)
5680
5681    def ResourceVar(self, vehicle, resource_group):
5682        r"""
5683        Returns the resource variable for the given vehicle index in the given
5684        resource group. If a vehicle doesn't require a resource from the
5685        corresponding resource group, then ResourceVar(v, r_g) == -1.
5686        """
5687        return _pywrapcp.RoutingModel_ResourceVar(self, vehicle, resource_group)
5688
5689    def CostVar(self):
5690        r""" Returns the global cost variable which is being minimized."""
5691        return _pywrapcp.RoutingModel_CostVar(self)
5692
5693    def GetArcCostForVehicle(self, from_index, to_index, vehicle):
5694        r"""
5695        Returns the cost of the transit arc between two nodes for a given vehicle.
5696        Input are variable indices of node. This returns 0 if vehicle < 0.
5697        """
5698        return _pywrapcp.RoutingModel_GetArcCostForVehicle(self, from_index, to_index, vehicle)
5699
5700    def CostsAreHomogeneousAcrossVehicles(self):
5701        r""" Whether costs are homogeneous across all vehicles."""
5702        return _pywrapcp.RoutingModel_CostsAreHomogeneousAcrossVehicles(self)
5703
5704    def GetHomogeneousCost(self, from_index, to_index):
5705        r"""
5706        Returns the cost of the segment between two nodes supposing all vehicle
5707        costs are the same (returns the cost for the first vehicle otherwise).
5708        """
5709        return _pywrapcp.RoutingModel_GetHomogeneousCost(self, from_index, to_index)
5710
5711    def GetArcCostForFirstSolution(self, from_index, to_index):
5712        r"""
5713        Returns the cost of the arc in the context of the first solution strategy.
5714        This is typically a simplification of the actual cost; see the .cc.
5715        """
5716        return _pywrapcp.RoutingModel_GetArcCostForFirstSolution(self, from_index, to_index)
5717
5718    def GetArcCostForClass(self, from_index, to_index, cost_class_index):
5719        r"""
5720        Returns the cost of the segment between two nodes for a given cost
5721        class. Input are variable indices of nodes and the cost class.
5722        Unlike GetArcCostForVehicle(), if cost_class is kNoCost, then the
5723        returned cost won't necessarily be zero: only some of the components
5724        of the cost that depend on the cost class will be omited. See the code
5725        for details.
5726        """
5727        return _pywrapcp.RoutingModel_GetArcCostForClass(self, from_index, to_index, cost_class_index)
5728
5729    def GetCostClassIndexOfVehicle(self, vehicle):
5730        r""" Get the cost class index of the given vehicle."""
5731        return _pywrapcp.RoutingModel_GetCostClassIndexOfVehicle(self, vehicle)
5732
5733    def HasVehicleWithCostClassIndex(self, cost_class_index):
5734        r"""
5735        Returns true iff the model contains a vehicle with the given
5736        cost_class_index.
5737        """
5738        return _pywrapcp.RoutingModel_HasVehicleWithCostClassIndex(self, cost_class_index)
5739
5740    def GetCostClassesCount(self):
5741        r""" Returns the number of different cost classes in the model."""
5742        return _pywrapcp.RoutingModel_GetCostClassesCount(self)
5743
5744    def GetNonZeroCostClassesCount(self):
5745        r""" Ditto, minus the 'always zero', built-in cost class."""
5746        return _pywrapcp.RoutingModel_GetNonZeroCostClassesCount(self)
5747
5748    def GetVehicleClassIndexOfVehicle(self, vehicle):
5749        return _pywrapcp.RoutingModel_GetVehicleClassIndexOfVehicle(self, vehicle)
5750
5751    def GetVehicleOfClass(self, vehicle_class):
5752        r"""
5753        Returns a vehicle of the given vehicle class, and -1 if there are no
5754        vehicles for this class.
5755        """
5756        return _pywrapcp.RoutingModel_GetVehicleOfClass(self, vehicle_class)
5757
5758    def GetVehicleClassesCount(self):
5759        r""" Returns the number of different vehicle classes in the model."""
5760        return _pywrapcp.RoutingModel_GetVehicleClassesCount(self)
5761
5762    def GetSameVehicleIndicesOfIndex(self, node):
5763        r""" Returns variable indices of nodes constrained to be on the same route."""
5764        return _pywrapcp.RoutingModel_GetSameVehicleIndicesOfIndex(self, node)
5765
5766    def GetVehicleTypeContainer(self):
5767        return _pywrapcp.RoutingModel_GetVehicleTypeContainer(self)
5768
5769    def ArcIsMoreConstrainedThanArc(self, _from, to1, to2):
5770        r"""
5771        Returns whether the arc from->to1 is more constrained than from->to2,
5772        taking into account, in order:
5773        - whether the destination node isn't an end node
5774        - whether the destination node is mandatory
5775        - whether the destination node is bound to the same vehicle as the source
5776        - the "primary constrained" dimension (see SetPrimaryConstrainedDimension)
5777        It then breaks ties using, in order:
5778        - the arc cost (taking unperformed penalties into account)
5779        - the size of the vehicle vars of "to1" and "to2" (lowest size wins)
5780        - the value: the lowest value of the indices to1 and to2 wins.
5781        See the .cc for details.
5782        The more constrained arc is typically preferable when building a
5783        first solution. This method is intended to be used as a callback for the
5784        BestValueByComparisonSelector value selector.
5785        Args:
5786          from: the variable index of the source node
5787          to1: the variable index of the first candidate destination node.
5788          to2: the variable index of the second candidate destination node.
5789        """
5790        return _pywrapcp.RoutingModel_ArcIsMoreConstrainedThanArc(self, _from, to1, to2)
5791
5792    def DebugOutputAssignment(self, solution_assignment, dimension_to_print):
5793        r"""
5794        Print some debugging information about an assignment, including the
5795        feasible intervals of the CumulVar for dimension "dimension_to_print"
5796        at each step of the routes.
5797        If "dimension_to_print" is omitted, all dimensions will be printed.
5798        """
5799        return _pywrapcp.RoutingModel_DebugOutputAssignment(self, solution_assignment, dimension_to_print)
5800
5801    def solver(self):
5802        r"""
5803        Returns a vector cumul_bounds, for which cumul_bounds[i][j] is a pair
5804        containing the minimum and maximum of the CumulVar of the jth node on
5805        route i.
5806        - cumul_bounds[i][j].first is the minimum.
5807        - cumul_bounds[i][j].second is the maximum.
5808        Returns the underlying constraint solver. Can be used to add extra
5809        constraints and/or modify search algorithms.
5810        """
5811        return _pywrapcp.RoutingModel_solver(self)
5812
5813    def CheckLimit(self, *args):
5814        r"""
5815        Returns true if the search limit has been crossed with the given time
5816        offset.
5817        """
5818        return _pywrapcp.RoutingModel_CheckLimit(self, *args)
5819
5820    def RemainingTime(self):
5821        r""" Returns the time left in the search limit."""
5822        return _pywrapcp.RoutingModel_RemainingTime(self)
5823
5824    def TimeBuffer(self):
5825        r""" Returns the time buffer to safely return a solution."""
5826        return _pywrapcp.RoutingModel_TimeBuffer(self)
5827
5828    def nodes(self):
5829        r"""
5830        Sizes and indices
5831        Returns the number of nodes in the model.
5832        """
5833        return _pywrapcp.RoutingModel_nodes(self)
5834
5835    def vehicles(self):
5836        r""" Returns the number of vehicle routes in the model."""
5837        return _pywrapcp.RoutingModel_vehicles(self)
5838
5839    def Size(self):
5840        r""" Returns the number of next variables in the model."""
5841        return _pywrapcp.RoutingModel_Size(self)
5842
5843    def GetNumberOfDecisionsInFirstSolution(self, search_parameters):
5844        r"""
5845        Returns statistics on first solution search, number of decisions sent to
5846        filters, number of decisions rejected by filters.
5847        """
5848        return _pywrapcp.RoutingModel_GetNumberOfDecisionsInFirstSolution(self, search_parameters)
5849
5850    def GetNumberOfRejectsInFirstSolution(self, search_parameters):
5851        return _pywrapcp.RoutingModel_GetNumberOfRejectsInFirstSolution(self, search_parameters)
5852
5853    def GetAutomaticFirstSolutionStrategy(self):
5854        r""" Returns the automatic first solution strategy selected."""
5855        return _pywrapcp.RoutingModel_GetAutomaticFirstSolutionStrategy(self)
5856
5857    def IsMatchingModel(self):
5858        r""" Returns true if a vehicle/node matching problem is detected."""
5859        return _pywrapcp.RoutingModel_IsMatchingModel(self)
5860
5861    def AreRoutesInterdependent(self, parameters):
5862        r"""
5863        Returns true if routes are interdependent. This means that any
5864        modification to a route might impact another.
5865        """
5866        return _pywrapcp.RoutingModel_AreRoutesInterdependent(self, parameters)
5867
5868    def MakeGuidedSlackFinalizer(self, dimension, initializer):
5869        r"""
5870        The next few members are in the public section only for testing purposes.
5871
5872        MakeGuidedSlackFinalizer creates a DecisionBuilder for the slacks of a
5873        dimension using a callback to choose which values to start with.
5874        The finalizer works only when all next variables in the model have
5875        been fixed. It has the following two characteristics:
5876        1. It follows the routes defined by the nexts variables when choosing a
5877           variable to make a decision on.
5878        2. When it comes to choose a value for the slack of node i, the decision
5879           builder first calls the callback with argument i, and supposingly the
5880           returned value is x it creates decisions slack[i] = x, slack[i] = x +
5881           1, slack[i] = x - 1, slack[i] = x + 2, etc.
5882        """
5883        return _pywrapcp.RoutingModel_MakeGuidedSlackFinalizer(self, dimension, initializer)
5884
5885    def MakeSelfDependentDimensionFinalizer(self, dimension):
5886        r"""
5887        MakeSelfDependentDimensionFinalizer is a finalizer for the slacks of a
5888        self-dependent dimension. It makes an extensive use of the caches of the
5889        state dependent transits.
5890        In detail, MakeSelfDependentDimensionFinalizer returns a composition of a
5891        local search decision builder with a greedy descent operator for the cumul
5892        of the start of each route and a guided slack finalizer. Provided there
5893        are no time windows and the maximum slacks are large enough, once the
5894        cumul of the start of route is fixed, the guided finalizer can find
5895        optimal values of the slacks for the rest of the route in time
5896        proportional to the length of the route. Therefore the composed finalizer
5897        generally works in time O(log(t)*n*m), where t is the latest possible
5898        departute time, n is the number of nodes in the network and m is the
5899        number of vehicles.
5900        """
5901        return _pywrapcp.RoutingModel_MakeSelfDependentDimensionFinalizer(self, dimension)
5902
5903# Register RoutingModel in _pywrapcp:
5904_pywrapcp.RoutingModel_swigregister(RoutingModel)
5905cvar = _pywrapcp.cvar
5906RoutingModel.kNoPenalty = _pywrapcp.cvar.RoutingModel_kNoPenalty
5907RoutingModel.kNoDisjunction = _pywrapcp.cvar.RoutingModel_kNoDisjunction
5908RoutingModel.kNoDimension = _pywrapcp.cvar.RoutingModel_kNoDimension
5909
5910class RoutingModelVisitor(BaseObject):
5911    r""" Routing model visitor."""
5912
5913    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
5914    __repr__ = _swig_repr
5915
5916    def __init__(self):
5917        _pywrapcp.RoutingModelVisitor_swiginit(self, _pywrapcp.new_RoutingModelVisitor())
5918    __swig_destroy__ = _pywrapcp.delete_RoutingModelVisitor
5919
5920# Register RoutingModelVisitor in _pywrapcp:
5921_pywrapcp.RoutingModelVisitor_swigregister(RoutingModelVisitor)
5922RoutingModelVisitor.kLightElement = _pywrapcp.cvar.RoutingModelVisitor_kLightElement
5923RoutingModelVisitor.kLightElement2 = _pywrapcp.cvar.RoutingModelVisitor_kLightElement2
5924RoutingModelVisitor.kRemoveValues = _pywrapcp.cvar.RoutingModelVisitor_kRemoveValues
5925
5926class GlobalVehicleBreaksConstraint(Constraint):
5927    r"""
5928    GlobalVehicleBreaksConstraint ensures breaks constraints are enforced on
5929    all vehicles in the dimension passed to its constructor.
5930    It is intended to be used for dimensions representing time.
5931    A break constraint ensures break intervals fit on the route of a vehicle.
5932    For a given vehicle, it forces break intervals to be disjoint from visit
5933    intervals, where visit intervals start at CumulVar(node) and last for
5934    node_visit_transit[node]. Moreover, it ensures that there is enough time
5935    between two consecutive nodes of a route to do transit and vehicle breaks,
5936    i.e. if Next(nodeA) = nodeB, CumulVar(nodeA) = tA and CumulVar(nodeB) = tB,
5937    then SlackVar(nodeA) >= sum_{breaks [tA, tB)} duration(break).
5938    """
5939
5940    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
5941    __repr__ = _swig_repr
5942
5943    def __init__(self, dimension):
5944        _pywrapcp.GlobalVehicleBreaksConstraint_swiginit(self, _pywrapcp.new_GlobalVehicleBreaksConstraint(dimension))
5945
5946    def DebugString(self):
5947        return _pywrapcp.GlobalVehicleBreaksConstraint_DebugString(self)
5948
5949    def Post(self):
5950        return _pywrapcp.GlobalVehicleBreaksConstraint_Post(self)
5951
5952    def InitialPropagateWrapper(self):
5953        return _pywrapcp.GlobalVehicleBreaksConstraint_InitialPropagateWrapper(self)
5954    __swig_destroy__ = _pywrapcp.delete_GlobalVehicleBreaksConstraint
5955
5956# Register GlobalVehicleBreaksConstraint in _pywrapcp:
5957_pywrapcp.GlobalVehicleBreaksConstraint_swigregister(GlobalVehicleBreaksConstraint)
5958class TypeRegulationsChecker(object):
5959    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
5960
5961    def __init__(self, *args, **kwargs):
5962        raise AttributeError("No constructor defined - class is abstract")
5963    __repr__ = _swig_repr
5964    __swig_destroy__ = _pywrapcp.delete_TypeRegulationsChecker
5965
5966    def CheckVehicle(self, vehicle, next_accessor):
5967        return _pywrapcp.TypeRegulationsChecker_CheckVehicle(self, vehicle, next_accessor)
5968
5969# Register TypeRegulationsChecker in _pywrapcp:
5970_pywrapcp.TypeRegulationsChecker_swigregister(TypeRegulationsChecker)
5971class TypeIncompatibilityChecker(TypeRegulationsChecker):
5972    r""" Checker for type incompatibilities."""
5973
5974    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
5975    __repr__ = _swig_repr
5976
5977    def __init__(self, model, check_hard_incompatibilities):
5978        _pywrapcp.TypeIncompatibilityChecker_swiginit(self, _pywrapcp.new_TypeIncompatibilityChecker(model, check_hard_incompatibilities))
5979    __swig_destroy__ = _pywrapcp.delete_TypeIncompatibilityChecker
5980
5981# Register TypeIncompatibilityChecker in _pywrapcp:
5982_pywrapcp.TypeIncompatibilityChecker_swigregister(TypeIncompatibilityChecker)
5983class TypeRequirementChecker(TypeRegulationsChecker):
5984    r""" Checker for type requirements."""
5985
5986    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
5987    __repr__ = _swig_repr
5988
5989    def __init__(self, model):
5990        _pywrapcp.TypeRequirementChecker_swiginit(self, _pywrapcp.new_TypeRequirementChecker(model))
5991    __swig_destroy__ = _pywrapcp.delete_TypeRequirementChecker
5992
5993# Register TypeRequirementChecker in _pywrapcp:
5994_pywrapcp.TypeRequirementChecker_swigregister(TypeRequirementChecker)
5995class TypeRegulationsConstraint(Constraint):
5996    r"""
5997    The following constraint ensures that incompatibilities and requirements
5998    between types are respected.
5999
6000    It verifies both "hard" and "temporal" incompatibilities.
6001    Two nodes with hard incompatible types cannot be served by the same vehicle
6002    at all, while with a temporal incompatibility they can't be on the same
6003    route at the same time.
6004    The VisitTypePolicy of a node determines how visiting it impacts the type
6005    count on the route.
6006
6007    For example, for
6008    - three temporally incompatible types T1 T2 and T3
6009    - 2 pairs of nodes a1/r1 and a2/r2 of type T1 and T2 respectively, with
6010        - a1 and a2 of VisitTypePolicy TYPE_ADDED_TO_VEHICLE
6011        - r1 and r2 of policy ADDED_TYPE_REMOVED_FROM_VEHICLE
6012    - 3 nodes A, UV and AR of type T3, respectively with type policies
6013      TYPE_ADDED_TO_VEHICLE, TYPE_ON_VEHICLE_UP_TO_VISIT and
6014      TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED
6015    the configurations
6016    UV --> a1 --> r1 --> a2 --> r2,   a1 --> r1 --> a2 --> r2 --> A and
6017    a1 --> r1 --> AR --> a2 --> r2 are acceptable, whereas the configurations
6018    a1 --> a2 --> r1 --> ..., or A --> a1 --> r1 --> ..., or
6019    a1 --> r1 --> UV --> ... are not feasible.
6020
6021    It also verifies same-vehicle and temporal type requirements.
6022    A node of type T_d with a same-vehicle requirement for type T_r needs to be
6023    served by the same vehicle as a node of type T_r.
6024    Temporal requirements, on the other hand, can take effect either when the
6025    dependent type is being added to the route or when it's removed from it,
6026    which is determined by the dependent node's VisitTypePolicy.
6027    In the above example:
6028    - If T3 is required on the same vehicle as T1, A, AR or UV must be on the
6029      same vehicle as a1.
6030    - If T2 is required when adding T1, a2 must be visited *before* a1, and if
6031      r2 is also visited on the route, it must be *after* a1, i.e. T2 must be on
6032      the vehicle when a1 is visited:
6033      ... --> a2 --> ... --> a1 --> ... --> r2 --> ...
6034    - If T3 is required when removing T1, T3 needs to be on the vehicle when
6035      r1 is visited:
6036      ... --> A --> ... --> r1 --> ...   OR   ... --> r1 --> ... --> UV --> ...
6037    """
6038
6039    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
6040    __repr__ = _swig_repr
6041
6042    def __init__(self, model):
6043        _pywrapcp.TypeRegulationsConstraint_swiginit(self, _pywrapcp.new_TypeRegulationsConstraint(model))
6044
6045    def Post(self):
6046        return _pywrapcp.TypeRegulationsConstraint_Post(self)
6047
6048    def InitialPropagateWrapper(self):
6049        return _pywrapcp.TypeRegulationsConstraint_InitialPropagateWrapper(self)
6050    __swig_destroy__ = _pywrapcp.delete_TypeRegulationsConstraint
6051
6052# Register TypeRegulationsConstraint in _pywrapcp:
6053_pywrapcp.TypeRegulationsConstraint_swigregister(TypeRegulationsConstraint)
6054class BoundCost(object):
6055    r"""
6056    A structure meant to store soft bounds and associated violation constants.
6057    It is 'Simple' because it has one BoundCost per element,
6058    in contrast to 'Multiple'. Design notes:
6059    - it is meant to store model information to be shared through pointers,
6060      so it disallows copy and assign to avoid accidental duplication.
6061    - it keeps soft bounds as an array of structs to help cache,
6062      because code that uses such bounds typically use both bound and cost.
6063    - soft bounds are named pairs, prevents some mistakes.
6064    - using operator[] to access elements is not interesting,
6065      because the structure will be accessed through pointers, moreover having
6066      to type bound_cost reminds the user of the order if they do a copy
6067      assignment of the element.
6068    """
6069
6070    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
6071    __repr__ = _swig_repr
6072    bound = property(_pywrapcp.BoundCost_bound_get, _pywrapcp.BoundCost_bound_set)
6073    cost = property(_pywrapcp.BoundCost_cost_get, _pywrapcp.BoundCost_cost_set)
6074
6075    def __init__(self, *args):
6076        _pywrapcp.BoundCost_swiginit(self, _pywrapcp.new_BoundCost(*args))
6077    __swig_destroy__ = _pywrapcp.delete_BoundCost
6078
6079# Register BoundCost in _pywrapcp:
6080_pywrapcp.BoundCost_swigregister(BoundCost)
6081class SimpleBoundCosts(object):
6082    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
6083    __repr__ = _swig_repr
6084
6085    def __init__(self, num_bounds, default_bound_cost):
6086        _pywrapcp.SimpleBoundCosts_swiginit(self, _pywrapcp.new_SimpleBoundCosts(num_bounds, default_bound_cost))
6087
6088    def bound_cost(self, element):
6089        return _pywrapcp.SimpleBoundCosts_bound_cost(self, element)
6090
6091    def size(self):
6092        return _pywrapcp.SimpleBoundCosts_size(self)
6093    __swig_destroy__ = _pywrapcp.delete_SimpleBoundCosts
6094
6095# Register SimpleBoundCosts in _pywrapcp:
6096_pywrapcp.SimpleBoundCosts_swigregister(SimpleBoundCosts)
6097class RoutingDimension(object):
6098    r"""
6099    Dimensions represent quantities accumulated at nodes along the routes. They
6100    represent quantities such as weights or volumes carried along the route, or
6101    distance or times.
6102
6103    Quantities at a node are represented by "cumul" variables and the increase
6104    or decrease of quantities between nodes are represented by "transit"
6105    variables. These variables are linked as follows:
6106
6107    if j == next(i),
6108    cumuls(j) = cumuls(i) + transits(i) + slacks(i) +
6109                state_dependent_transits(i)
6110
6111    where slack is a positive slack variable (can represent waiting times for
6112    a time dimension), and state_dependent_transits is a non-purely functional
6113    version of transits_. Favour transits over state_dependent_transits when
6114    possible, because purely functional callbacks allow more optimisations and
6115    make the model faster and easier to solve.
6116    for a given vehicle, it is passed as an external vector, it would be better
6117    to have this information here.
6118    """
6119
6120    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
6121
6122    def __init__(self, *args, **kwargs):
6123        raise AttributeError("No constructor defined")
6124    __repr__ = _swig_repr
6125    __swig_destroy__ = _pywrapcp.delete_RoutingDimension
6126
6127    def model(self):
6128        r""" Returns the model on which the dimension was created."""
6129        return _pywrapcp.RoutingDimension_model(self)
6130
6131    def GetTransitValue(self, from_index, to_index, vehicle):
6132        r"""
6133        Returns the transition value for a given pair of nodes (as var index);
6134        this value is the one taken by the corresponding transit variable when
6135        the 'next' variable for 'from_index' is bound to 'to_index'.
6136        """
6137        return _pywrapcp.RoutingDimension_GetTransitValue(self, from_index, to_index, vehicle)
6138
6139    def GetTransitValueFromClass(self, from_index, to_index, vehicle_class):
6140        r"""
6141        Same as above but taking a vehicle class of the dimension instead of a
6142        vehicle (the class of a vehicle can be obtained with vehicle_to_class()).
6143        """
6144        return _pywrapcp.RoutingDimension_GetTransitValueFromClass(self, from_index, to_index, vehicle_class)
6145
6146    def CumulVar(self, index):
6147        r"""
6148        Get the cumul, transit and slack variables for the given node (given as
6149        int64_t var index).
6150        """
6151        return _pywrapcp.RoutingDimension_CumulVar(self, index)
6152
6153    def TransitVar(self, index):
6154        return _pywrapcp.RoutingDimension_TransitVar(self, index)
6155
6156    def FixedTransitVar(self, index):
6157        return _pywrapcp.RoutingDimension_FixedTransitVar(self, index)
6158
6159    def SlackVar(self, index):
6160        return _pywrapcp.RoutingDimension_SlackVar(self, index)
6161
6162    def SetSpanUpperBoundForVehicle(self, upper_bound, vehicle):
6163        r"""
6164        Sets an upper bound on the dimension span on a given vehicle. This is the
6165        preferred way to limit the "length" of the route of a vehicle according to
6166        a dimension.
6167        """
6168        return _pywrapcp.RoutingDimension_SetSpanUpperBoundForVehicle(self, upper_bound, vehicle)
6169
6170    def SetSpanCostCoefficientForVehicle(self, coefficient, vehicle):
6171        r"""
6172        Sets a cost proportional to the dimension span on a given vehicle,
6173        or on all vehicles at once. "coefficient" must be nonnegative.
6174        This is handy to model costs proportional to idle time when the dimension
6175        represents time.
6176        The cost for a vehicle is
6177          span_cost = coefficient * (dimension end value - dimension start value).
6178        """
6179        return _pywrapcp.RoutingDimension_SetSpanCostCoefficientForVehicle(self, coefficient, vehicle)
6180
6181    def SetSpanCostCoefficientForAllVehicles(self, coefficient):
6182        return _pywrapcp.RoutingDimension_SetSpanCostCoefficientForAllVehicles(self, coefficient)
6183
6184    def SetGlobalSpanCostCoefficient(self, coefficient):
6185        r"""
6186        Sets a cost proportional to the *global* dimension span, that is the
6187        difference between the largest value of route end cumul variables and
6188        the smallest value of route start cumul variables.
6189        In other words:
6190        global_span_cost =
6191          coefficient * (Max(dimension end value) - Min(dimension start value)).
6192        """
6193        return _pywrapcp.RoutingDimension_SetGlobalSpanCostCoefficient(self, coefficient)
6194
6195    def SetCumulVarSoftUpperBound(self, index, upper_bound, coefficient):
6196        r"""
6197        Sets a soft upper bound to the cumul variable of a given variable index.
6198        If the value of the cumul variable is greater than the bound, a cost
6199        proportional to the difference between this value and the bound is added
6200        to the cost function of the model:
6201          cumulVar <= upper_bound -> cost = 0
6202           cumulVar > upper_bound -> cost = coefficient * (cumulVar - upper_bound)
6203        This is also handy to model tardiness costs when the dimension represents
6204        time.
6205        """
6206        return _pywrapcp.RoutingDimension_SetCumulVarSoftUpperBound(self, index, upper_bound, coefficient)
6207
6208    def HasCumulVarSoftUpperBound(self, index):
6209        r"""
6210        Returns true if a soft upper bound has been set for a given variable
6211        index.
6212        """
6213        return _pywrapcp.RoutingDimension_HasCumulVarSoftUpperBound(self, index)
6214
6215    def GetCumulVarSoftUpperBound(self, index):
6216        r"""
6217        Returns the soft upper bound of a cumul variable for a given variable
6218        index. The "hard" upper bound of the variable is returned if no soft upper
6219        bound has been set.
6220        """
6221        return _pywrapcp.RoutingDimension_GetCumulVarSoftUpperBound(self, index)
6222
6223    def GetCumulVarSoftUpperBoundCoefficient(self, index):
6224        r"""
6225        Returns the cost coefficient of the soft upper bound of a cumul variable
6226        for a given variable index. If no soft upper bound has been set, 0 is
6227        returned.
6228        """
6229        return _pywrapcp.RoutingDimension_GetCumulVarSoftUpperBoundCoefficient(self, index)
6230
6231    def SetCumulVarSoftLowerBound(self, index, lower_bound, coefficient):
6232        r"""
6233        Sets a soft lower bound to the cumul variable of a given variable index.
6234        If the value of the cumul variable is less than the bound, a cost
6235        proportional to the difference between this value and the bound is added
6236        to the cost function of the model:
6237          cumulVar > lower_bound -> cost = 0
6238          cumulVar <= lower_bound -> cost = coefficient * (lower_bound -
6239                      cumulVar).
6240        This is also handy to model earliness costs when the dimension represents
6241        time.
6242        """
6243        return _pywrapcp.RoutingDimension_SetCumulVarSoftLowerBound(self, index, lower_bound, coefficient)
6244
6245    def HasCumulVarSoftLowerBound(self, index):
6246        r"""
6247        Returns true if a soft lower bound has been set for a given variable
6248        index.
6249        """
6250        return _pywrapcp.RoutingDimension_HasCumulVarSoftLowerBound(self, index)
6251
6252    def GetCumulVarSoftLowerBound(self, index):
6253        r"""
6254        Returns the soft lower bound of a cumul variable for a given variable
6255        index. The "hard" lower bound of the variable is returned if no soft lower
6256        bound has been set.
6257        """
6258        return _pywrapcp.RoutingDimension_GetCumulVarSoftLowerBound(self, index)
6259
6260    def GetCumulVarSoftLowerBoundCoefficient(self, index):
6261        r"""
6262        Returns the cost coefficient of the soft lower bound of a cumul variable
6263        for a given variable index. If no soft lower bound has been set, 0 is
6264        returned.
6265        """
6266        return _pywrapcp.RoutingDimension_GetCumulVarSoftLowerBoundCoefficient(self, index)
6267
6268    def SetBreakIntervalsOfVehicle(self, breaks, vehicle, node_visit_transits):
6269        r"""
6270        Sets the breaks for a given vehicle. Breaks are represented by
6271        IntervalVars. They may interrupt transits between nodes and increase
6272        the value of corresponding slack variables.
6273        A break may take place before the start of a vehicle, after the end of
6274        a vehicle, or during a travel i -> j.
6275
6276        In that case, the interval [break.Start(), break.End()) must be a subset
6277        of [CumulVar(i) + pre_travel(i, j), CumulVar(j) - post_travel(i, j)). In
6278        other words, a break may not overlap any node n's visit, given by
6279        [CumulVar(n) - post_travel(_, n), CumulVar(n) + pre_travel(n, _)).
6280        This formula considers post_travel(_, start) and pre_travel(end, _) to be
6281        0; pre_travel will never be called on any (_, start) and post_travel will
6282        never we called on any (end, _). If pre_travel_evaluator or
6283        post_travel_evaluator is -1, it will be taken as a function that always
6284        returns 0.
6285        Deprecated, sets pre_travel(i, j) = node_visit_transit[i].
6286        """
6287        return _pywrapcp.RoutingDimension_SetBreakIntervalsOfVehicle(self, breaks, vehicle, node_visit_transits)
6288
6289    def SetBreakDistanceDurationOfVehicle(self, distance, duration, vehicle):
6290        r"""
6291        With breaks supposed to be consecutive, this forces the distance between
6292        breaks of size at least minimum_break_duration to be at most distance.
6293        This supposes that the time until route start and after route end are
6294        infinite breaks.
6295        """
6296        return _pywrapcp.RoutingDimension_SetBreakDistanceDurationOfVehicle(self, distance, duration, vehicle)
6297
6298    def InitializeBreaks(self):
6299        r"""
6300        Sets up vehicle_break_intervals_, vehicle_break_distance_duration_,
6301        pre_travel_evaluators and post_travel_evaluators.
6302        """
6303        return _pywrapcp.RoutingDimension_InitializeBreaks(self)
6304
6305    def HasBreakConstraints(self):
6306        r""" Returns true if any break interval or break distance was defined."""
6307        return _pywrapcp.RoutingDimension_HasBreakConstraints(self)
6308
6309    def GetPreTravelEvaluatorOfVehicle(self, vehicle):
6310        return _pywrapcp.RoutingDimension_GetPreTravelEvaluatorOfVehicle(self, vehicle)
6311
6312    def GetPostTravelEvaluatorOfVehicle(self, vehicle):
6313        return _pywrapcp.RoutingDimension_GetPostTravelEvaluatorOfVehicle(self, vehicle)
6314
6315    def base_dimension(self):
6316        r""" Returns the parent in the dependency tree if any or nullptr otherwise."""
6317        return _pywrapcp.RoutingDimension_base_dimension(self)
6318
6319    def ShortestTransitionSlack(self, node):
6320        r"""
6321        It makes sense to use the function only for self-dependent dimension.
6322        For such dimensions the value of the slack of a node determines the
6323        transition cost of the next transit. Provided that
6324          1. cumul[node] is fixed,
6325          2. next[node] and next[next[node]] (if exists) are fixed,
6326        the value of slack[node] for which cumul[next[node]] + transit[next[node]]
6327        is minimized can be found in O(1) using this function.
6328        """
6329        return _pywrapcp.RoutingDimension_ShortestTransitionSlack(self, node)
6330
6331    def name(self):
6332        r""" Returns the name of the dimension."""
6333        return _pywrapcp.RoutingDimension_name(self)
6334
6335    def SetPickupToDeliveryLimitFunctionForPair(self, limit_function, pair_index):
6336        return _pywrapcp.RoutingDimension_SetPickupToDeliveryLimitFunctionForPair(self, limit_function, pair_index)
6337
6338    def HasPickupToDeliveryLimits(self):
6339        return _pywrapcp.RoutingDimension_HasPickupToDeliveryLimits(self)
6340
6341    def AddNodePrecedence(self, first_node, second_node, offset):
6342        return _pywrapcp.RoutingDimension_AddNodePrecedence(self, first_node, second_node, offset)
6343
6344    def GetSpanUpperBoundForVehicle(self, vehicle):
6345        return _pywrapcp.RoutingDimension_GetSpanUpperBoundForVehicle(self, vehicle)
6346
6347    def GetSpanCostCoefficientForVehicle(self, vehicle):
6348        return _pywrapcp.RoutingDimension_GetSpanCostCoefficientForVehicle(self, vehicle)
6349
6350    def global_span_cost_coefficient(self):
6351        return _pywrapcp.RoutingDimension_global_span_cost_coefficient(self)
6352
6353    def GetGlobalOptimizerOffset(self):
6354        return _pywrapcp.RoutingDimension_GetGlobalOptimizerOffset(self)
6355
6356    def GetLocalOptimizerOffsetForVehicle(self, vehicle):
6357        return _pywrapcp.RoutingDimension_GetLocalOptimizerOffsetForVehicle(self, vehicle)
6358
6359    def SetSoftSpanUpperBoundForVehicle(self, bound_cost, vehicle):
6360        r"""
6361        If the span of vehicle on this dimension is larger than bound,
6362        the cost will be increased by cost * (span - bound).
6363        """
6364        return _pywrapcp.RoutingDimension_SetSoftSpanUpperBoundForVehicle(self, bound_cost, vehicle)
6365
6366    def HasSoftSpanUpperBounds(self):
6367        return _pywrapcp.RoutingDimension_HasSoftSpanUpperBounds(self)
6368
6369    def GetSoftSpanUpperBoundForVehicle(self, vehicle):
6370        return _pywrapcp.RoutingDimension_GetSoftSpanUpperBoundForVehicle(self, vehicle)
6371
6372    def SetQuadraticCostSoftSpanUpperBoundForVehicle(self, bound_cost, vehicle):
6373        r"""
6374        If the span of vehicle on this dimension is larger than bound,
6375        the cost will be increased by cost * (span - bound)^2.
6376        """
6377        return _pywrapcp.RoutingDimension_SetQuadraticCostSoftSpanUpperBoundForVehicle(self, bound_cost, vehicle)
6378
6379    def HasQuadraticCostSoftSpanUpperBounds(self):
6380        return _pywrapcp.RoutingDimension_HasQuadraticCostSoftSpanUpperBounds(self)
6381
6382    def GetQuadraticCostSoftSpanUpperBoundForVehicle(self, vehicle):
6383        return _pywrapcp.RoutingDimension_GetQuadraticCostSoftSpanUpperBoundForVehicle(self, vehicle)
6384
6385# Register RoutingDimension in _pywrapcp:
6386_pywrapcp.RoutingDimension_swigregister(RoutingDimension)
6387
6388def MakeSetValuesFromTargets(solver, variables, targets):
6389    r"""
6390    A decision builder which tries to assign values to variables as close as
6391    possible to target values first.
6392    """
6393    return _pywrapcp.MakeSetValuesFromTargets(solver, variables, targets)
6394
6395def SolveModelWithSat(model, search_parameters, initial_solution, solution):
6396    r"""
6397    Attempts to solve the model using the cp-sat solver. As of 5/2019, will
6398    solve the TSP corresponding to the model if it has a single vehicle.
6399    Therefore the resulting solution might not actually be feasible. Will return
6400    false if a solution could not be found.
6401    """
6402    return _pywrapcp.SolveModelWithSat(model, search_parameters, initial_solution, solution)
class DefaultPhaseParameters:
 64class DefaultPhaseParameters(object):
 65    r"""
 66    This struct holds all parameters for the default search.
 67    DefaultPhaseParameters is only used by Solver::MakeDefaultPhase methods.
 68    Note this is for advanced users only.
 69    """
 70
 71    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
 72    __repr__ = _swig_repr
 73    CHOOSE_MAX_SUM_IMPACT = _pywrapcp.DefaultPhaseParameters_CHOOSE_MAX_SUM_IMPACT
 74    CHOOSE_MAX_AVERAGE_IMPACT = _pywrapcp.DefaultPhaseParameters_CHOOSE_MAX_AVERAGE_IMPACT
 75    CHOOSE_MAX_VALUE_IMPACT = _pywrapcp.DefaultPhaseParameters_CHOOSE_MAX_VALUE_IMPACT
 76    SELECT_MIN_IMPACT = _pywrapcp.DefaultPhaseParameters_SELECT_MIN_IMPACT
 77    SELECT_MAX_IMPACT = _pywrapcp.DefaultPhaseParameters_SELECT_MAX_IMPACT
 78    NONE = _pywrapcp.DefaultPhaseParameters_NONE
 79    NORMAL = _pywrapcp.DefaultPhaseParameters_NORMAL
 80    VERBOSE = _pywrapcp.DefaultPhaseParameters_VERBOSE
 81    var_selection_schema = property(_pywrapcp.DefaultPhaseParameters_var_selection_schema_get, _pywrapcp.DefaultPhaseParameters_var_selection_schema_set, doc=r"""
 82    This parameter describes how the next variable to instantiate
 83    will be chosen.
 84    """)
 85    value_selection_schema = property(_pywrapcp.DefaultPhaseParameters_value_selection_schema_get, _pywrapcp.DefaultPhaseParameters_value_selection_schema_set, doc=r""" This parameter describes which value to select for a given var.""")
 86    initialization_splits = property(_pywrapcp.DefaultPhaseParameters_initialization_splits_get, _pywrapcp.DefaultPhaseParameters_initialization_splits_set, doc=r"""
 87    Maximum number of intervals that the initialization of impacts will scan
 88    per variable.
 89    """)
 90    run_all_heuristics = property(_pywrapcp.DefaultPhaseParameters_run_all_heuristics_get, _pywrapcp.DefaultPhaseParameters_run_all_heuristics_set, doc=r"""
 91    The default phase will run heuristics periodically. This parameter
 92    indicates if we should run all heuristics, or a randomly selected
 93    one.
 94    """)
 95    heuristic_period = property(_pywrapcp.DefaultPhaseParameters_heuristic_period_get, _pywrapcp.DefaultPhaseParameters_heuristic_period_set, doc=r"""
 96    The distance in nodes between each run of the heuristics. A
 97    negative or null value will mean that we will not run heuristics
 98    at all.
 99    """)
100    heuristic_num_failures_limit = property(_pywrapcp.DefaultPhaseParameters_heuristic_num_failures_limit_get, _pywrapcp.DefaultPhaseParameters_heuristic_num_failures_limit_set, doc=r""" The failure limit for each heuristic that we run.""")
101    persistent_impact = property(_pywrapcp.DefaultPhaseParameters_persistent_impact_get, _pywrapcp.DefaultPhaseParameters_persistent_impact_set, doc=r"""
102    Whether to keep the impact from the first search for other searches,
103    or to recompute the impact for each new search.
104    """)
105    random_seed = property(_pywrapcp.DefaultPhaseParameters_random_seed_get, _pywrapcp.DefaultPhaseParameters_random_seed_set, doc=r""" Seed used to initialize the random part in some heuristics.""")
106    display_level = property(_pywrapcp.DefaultPhaseParameters_display_level_get, _pywrapcp.DefaultPhaseParameters_display_level_set, doc=r"""
107    This represents the amount of information displayed by the default search.
108    NONE means no display, VERBOSE means extra information.
109    """)
110    decision_builder = property(_pywrapcp.DefaultPhaseParameters_decision_builder_get, _pywrapcp.DefaultPhaseParameters_decision_builder_set, doc=r""" When defined, this overrides the default impact based decision builder.""")
111
112    def __init__(self):
113        _pywrapcp.DefaultPhaseParameters_swiginit(self, _pywrapcp.new_DefaultPhaseParameters())
114    __swig_destroy__ = _pywrapcp.delete_DefaultPhaseParameters

This struct holds all parameters for the default search. DefaultPhaseParameters is only used by Solver::MakeDefaultPhase methods. Note this is for advanced users only.

DefaultPhaseParameters()
112    def __init__(self):
113        _pywrapcp.DefaultPhaseParameters_swiginit(self, _pywrapcp.new_DefaultPhaseParameters())
thisown

The membership flag

var_selection_schema

This parameter describes how the next variable to instantiate will be chosen.

value_selection_schema

This parameter describes which value to select for a given var.

initialization_splits

Maximum number of intervals that the initialization of impacts will scan per variable.

run_all_heuristics

The default phase will run heuristics periodically. This parameter indicates if we should run all heuristics, or a randomly selected one.

heuristic_period

The distance in nodes between each run of the heuristics. A negative or null value will mean that we will not run heuristics at all.

heuristic_num_failures_limit

The failure limit for each heuristic that we run.

persistent_impact

Whether to keep the impact from the first search for other searches, or to recompute the impact for each new search.

random_seed

Seed used to initialize the random part in some heuristics.

display_level

This represents the amount of information displayed by the default search. NONE means no display, VERBOSE means extra information.

decision_builder

When defined, this overrides the default impact based decision builder.

class Solver:
 118class Solver(object):
 119    r"""
 120    Solver Class
 121
 122    A solver represents the main computation engine. It implements the entire
 123    range of Constraint Programming protocols:
 124      - Reversibility
 125      - Propagation
 126      - Search
 127
 128    Usually, Constraint Programming code consists of
 129      - the creation of the Solver,
 130      - the creation of the decision variables of the model,
 131      - the creation of the constraints of the model and their addition to the
 132        solver() through the AddConstraint() method,
 133      - the creation of the main DecisionBuilder class,
 134      - the launch of the solve() method with the decision builder.
 135
 136    For the time being, Solver is neither MT_SAFE nor MT_HOT.
 137    """
 138
 139    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
 140    __repr__ = _swig_repr
 141    INT_VAR_DEFAULT = _pywrapcp.Solver_INT_VAR_DEFAULT
 142    r""" The default behavior is CHOOSE_FIRST_UNBOUND."""
 143    INT_VAR_SIMPLE = _pywrapcp.Solver_INT_VAR_SIMPLE
 144    r""" The simple selection is CHOOSE_FIRST_UNBOUND."""
 145    CHOOSE_FIRST_UNBOUND = _pywrapcp.Solver_CHOOSE_FIRST_UNBOUND
 146    r"""
 147    Select the first unbound variable.
 148    Variables are considered in the order of the vector of IntVars used
 149    to create the selector.
 150    """
 151    CHOOSE_RANDOM = _pywrapcp.Solver_CHOOSE_RANDOM
 152    r""" Randomly select one of the remaining unbound variables."""
 153    CHOOSE_MIN_SIZE_LOWEST_MIN = _pywrapcp.Solver_CHOOSE_MIN_SIZE_LOWEST_MIN
 154    r"""
 155    Among unbound variables, select the variable with the smallest size,
 156    i.e., the smallest number of possible values.
 157    In case of a tie, the selected variables is the one with the lowest min
 158    value.
 159    In case of a tie, the first one is selected, first being defined by the
 160    order in the vector of IntVars used to create the selector.
 161    """
 162    CHOOSE_MIN_SIZE_HIGHEST_MIN = _pywrapcp.Solver_CHOOSE_MIN_SIZE_HIGHEST_MIN
 163    r"""
 164    Among unbound variables, select the variable with the smallest size,
 165    i.e., the smallest number of possible values.
 166    In case of a tie, the selected variable is the one with the highest min
 167    value.
 168    In case of a tie, the first one is selected, first being defined by the
 169    order in the vector of IntVars used to create the selector.
 170    """
 171    CHOOSE_MIN_SIZE_LOWEST_MAX = _pywrapcp.Solver_CHOOSE_MIN_SIZE_LOWEST_MAX
 172    r"""
 173    Among unbound variables, select the variable with the smallest size,
 174    i.e., the smallest number of possible values.
 175    In case of a tie, the selected variables is the one with the lowest max
 176    value.
 177    In case of a tie, the first one is selected, first being defined by the
 178    order in the vector of IntVars used to create the selector.
 179    """
 180    CHOOSE_MIN_SIZE_HIGHEST_MAX = _pywrapcp.Solver_CHOOSE_MIN_SIZE_HIGHEST_MAX
 181    r"""
 182    Among unbound variables, select the variable with the smallest size,
 183    i.e., the smallest number of possible values.
 184    In case of a tie, the selected variable is the one with the highest max
 185    value.
 186    In case of a tie, the first one is selected, first being defined by the
 187    order in the vector of IntVars used to create the selector.
 188    """
 189    CHOOSE_LOWEST_MIN = _pywrapcp.Solver_CHOOSE_LOWEST_MIN
 190    r"""
 191    Among unbound variables, select the variable with the smallest minimal
 192    value.
 193    In case of a tie, the first one is selected, "first" defined by the
 194    order in the vector of IntVars used to create the selector.
 195    """
 196    CHOOSE_HIGHEST_MAX = _pywrapcp.Solver_CHOOSE_HIGHEST_MAX
 197    r"""
 198    Among unbound variables, select the variable with the highest maximal
 199    value.
 200    In case of a tie, the first one is selected, first being defined by the
 201    order in the vector of IntVars used to create the selector.
 202    """
 203    CHOOSE_MIN_SIZE = _pywrapcp.Solver_CHOOSE_MIN_SIZE
 204    r"""
 205    Among unbound variables, select the variable with the smallest size.
 206    In case of a tie, the first one is selected, first being defined by the
 207    order in the vector of IntVars used to create the selector.
 208    """
 209    CHOOSE_MAX_SIZE = _pywrapcp.Solver_CHOOSE_MAX_SIZE
 210    r"""
 211    Among unbound variables, select the variable with the highest size.
 212    In case of a tie, the first one is selected, first being defined by the
 213    order in the vector of IntVars used to create the selector.
 214    """
 215    CHOOSE_MAX_REGRET_ON_MIN = _pywrapcp.Solver_CHOOSE_MAX_REGRET_ON_MIN
 216    r"""
 217    Among unbound variables, select the variable with the largest
 218    gap between the first and the second values of the domain.
 219    """
 220    CHOOSE_PATH = _pywrapcp.Solver_CHOOSE_PATH
 221    r"""
 222    Selects the next unbound variable on a path, the path being defined by
 223    the variables: var[i] corresponds to the index of the next of i.
 224    """
 225    INT_VALUE_DEFAULT = _pywrapcp.Solver_INT_VALUE_DEFAULT
 226    r""" The default behavior is ASSIGN_MIN_VALUE."""
 227    INT_VALUE_SIMPLE = _pywrapcp.Solver_INT_VALUE_SIMPLE
 228    r""" The simple selection is ASSIGN_MIN_VALUE."""
 229    ASSIGN_MIN_VALUE = _pywrapcp.Solver_ASSIGN_MIN_VALUE
 230    r""" Selects the min value of the selected variable."""
 231    ASSIGN_MAX_VALUE = _pywrapcp.Solver_ASSIGN_MAX_VALUE
 232    r""" Selects the max value of the selected variable."""
 233    ASSIGN_RANDOM_VALUE = _pywrapcp.Solver_ASSIGN_RANDOM_VALUE
 234    r""" Selects randomly one of the possible values of the selected variable."""
 235    ASSIGN_CENTER_VALUE = _pywrapcp.Solver_ASSIGN_CENTER_VALUE
 236    r"""
 237    Selects the first possible value which is the closest to the center
 238    of the domain of the selected variable.
 239    The center is defined as (min + max) / 2.
 240    """
 241    SPLIT_LOWER_HALF = _pywrapcp.Solver_SPLIT_LOWER_HALF
 242    r"""
 243    Split the domain in two around the center, and choose the lower
 244    part first.
 245    """
 246    SPLIT_UPPER_HALF = _pywrapcp.Solver_SPLIT_UPPER_HALF
 247    r"""
 248    Split the domain in two around the center, and choose the lower
 249    part first.
 250    """
 251    SEQUENCE_DEFAULT = _pywrapcp.Solver_SEQUENCE_DEFAULT
 252    SEQUENCE_SIMPLE = _pywrapcp.Solver_SEQUENCE_SIMPLE
 253    CHOOSE_MIN_SLACK_RANK_FORWARD = _pywrapcp.Solver_CHOOSE_MIN_SLACK_RANK_FORWARD
 254    CHOOSE_RANDOM_RANK_FORWARD = _pywrapcp.Solver_CHOOSE_RANDOM_RANK_FORWARD
 255    INTERVAL_DEFAULT = _pywrapcp.Solver_INTERVAL_DEFAULT
 256    r""" The default is INTERVAL_SET_TIMES_FORWARD."""
 257    INTERVAL_SIMPLE = _pywrapcp.Solver_INTERVAL_SIMPLE
 258    r""" The simple is INTERVAL_SET_TIMES_FORWARD."""
 259    INTERVAL_SET_TIMES_FORWARD = _pywrapcp.Solver_INTERVAL_SET_TIMES_FORWARD
 260    r"""
 261    Selects the variable with the lowest starting time of all variables,
 262    and fixes its starting time to this lowest value.
 263    """
 264    INTERVAL_SET_TIMES_BACKWARD = _pywrapcp.Solver_INTERVAL_SET_TIMES_BACKWARD
 265    r"""
 266    Selects the variable with the highest ending time of all variables,
 267    and fixes the ending time to this highest values.
 268    """
 269    TWOOPT = _pywrapcp.Solver_TWOOPT
 270    r"""
 271    Operator which reverses a sub-chain of a path. It is called TwoOpt
 272    because it breaks two arcs on the path; resulting paths are called
 273    two-optimal.
 274    Possible neighbors for the path 1 -> 2 -> 3 -> 4 -> 5
 275    (where (1, 5) are first and last nodes of the path and can therefore not
 276    be moved):
 277      1 -> [3 -> 2] -> 4  -> 5
 278      1 -> [4 -> 3  -> 2] -> 5
 279      1 ->  2 -> [4 -> 3] -> 5
 280    """
 281    OROPT = _pywrapcp.Solver_OROPT
 282    r"""
 283    Relocate: OROPT and RELOCATE.
 284    Operator which moves a sub-chain of a path to another position; the
 285    specified chain length is the fixed length of the chains being moved.
 286    When this length is 1, the operator simply moves a node to another
 287    position.
 288    Possible neighbors for the path 1 -> 2 -> 3 -> 4 -> 5, for a chain
 289    length of 2 (where (1, 5) are first and last nodes of the path and can
 290    therefore not be moved):
 291      1 ->  4 -> [2 -> 3] -> 5
 292      1 -> [3 -> 4] -> 2  -> 5
 293
 294    Using Relocate with chain lengths of 1, 2 and 3 together is equivalent
 295    to the OrOpt operator on a path. The OrOpt operator is a limited
 296     version of 3Opt (breaks 3 arcs on a path).
 297    """
 298    RELOCATE = _pywrapcp.Solver_RELOCATE
 299    r""" Relocate neighborhood with length of 1 (see OROPT comment)."""
 300    EXCHANGE = _pywrapcp.Solver_EXCHANGE
 301    r"""
 302    Operator which exchanges the positions of two nodes.
 303    Possible neighbors for the path 1 -> 2 -> 3 -> 4 -> 5
 304    (where (1, 5) are first and last nodes of the path and can therefore not
 305    be moved):
 306      1 -> [3] -> [2] ->  4  -> 5
 307      1 -> [4] ->  3  -> [2] -> 5
 308      1 ->  2  -> [4] -> [3] -> 5
 309    """
 310    CROSS = _pywrapcp.Solver_CROSS
 311    r"""
 312    Operator which cross exchanges the starting chains of 2 paths, including
 313    exchanging the whole paths.
 314    First and last nodes are not moved.
 315    Possible neighbors for the paths 1 -> 2 -> 3 -> 4 -> 5 and 6 -> 7 -> 8
 316    (where (1, 5) and (6, 8) are first and last nodes of the paths and can
 317    therefore not be moved):
 318      1 -> [7] -> 3 -> 4 -> 5  6 -> [2] -> 8
 319      1 -> [7] -> 4 -> 5       6 -> [2 -> 3] -> 8
 320      1 -> [7] -> 5            6 -> [2 -> 3 -> 4] -> 8
 321    """
 322    MAKEACTIVE = _pywrapcp.Solver_MAKEACTIVE
 323    r"""
 324    Operator which inserts an inactive node into a path.
 325    Possible neighbors for the path 1 -> 2 -> 3 -> 4 with 5 inactive
 326    (where 1 and 4 are first and last nodes of the path) are:
 327      1 -> [5] ->  2  ->  3  -> 4
 328      1 ->  2  -> [5] ->  3  -> 4
 329      1 ->  2  ->  3  -> [5] -> 4
 330    """
 331    MAKEINACTIVE = _pywrapcp.Solver_MAKEINACTIVE
 332    r"""
 333    Operator which makes path nodes inactive.
 334    Possible neighbors for the path 1 -> 2 -> 3 -> 4 (where 1 and 4 are
 335    first and last nodes of the path) are:
 336      1 -> 3 -> 4 with 2 inactive
 337      1 -> 2 -> 4 with 3 inactive
 338    """
 339    MAKECHAININACTIVE = _pywrapcp.Solver_MAKECHAININACTIVE
 340    r"""
 341    Operator which makes a "chain" of path nodes inactive.
 342    Possible neighbors for the path 1 -> 2 -> 3 -> 4 (where 1 and 4 are
 343    first and last nodes of the path) are:
 344      1 -> 3 -> 4 with 2 inactive
 345      1 -> 2 -> 4 with 3 inactive
 346      1 -> 4 with 2 and 3 inactive
 347    """
 348    SWAPACTIVE = _pywrapcp.Solver_SWAPACTIVE
 349    r"""
 350    Operator which replaces an active node by an inactive one.
 351    Possible neighbors for the path 1 -> 2 -> 3 -> 4 with 5 inactive
 352    (where 1 and 4 are first and last nodes of the path) are:
 353      1 -> [5] ->  3  -> 4 with 2 inactive
 354      1 ->  2  -> [5] -> 4 with 3 inactive
 355    """
 356    EXTENDEDSWAPACTIVE = _pywrapcp.Solver_EXTENDEDSWAPACTIVE
 357    r"""
 358    Operator which makes an inactive node active and an active one inactive.
 359    It is similar to SwapActiveOperator except that it tries to insert the
 360    inactive node in all possible positions instead of just the position of
 361    the node made inactive.
 362    Possible neighbors for the path 1 -> 2 -> 3 -> 4 with 5 inactive
 363    (where 1 and 4 are first and last nodes of the path) are:
 364      1 -> [5] ->  3  -> 4 with 2 inactive
 365      1 ->  3  -> [5] -> 4 with 2 inactive
 366      1 -> [5] ->  2  -> 4 with 3 inactive
 367      1 ->  2  -> [5] -> 4 with 3 inactive
 368    """
 369    PATHLNS = _pywrapcp.Solver_PATHLNS
 370    r"""
 371    Operator which relaxes two sub-chains of three consecutive arcs each.
 372    Each sub-chain is defined by a start node and the next three arcs. Those
 373    six arcs are relaxed to build a new neighbor.
 374    PATHLNS explores all possible pairs of starting nodes and so defines
 375    n^2 neighbors, n being the number of nodes.
 376    Note that the two sub-chains can be part of the same path; they even may
 377    overlap.
 378    """
 379    FULLPATHLNS = _pywrapcp.Solver_FULLPATHLNS
 380    r"""
 381    Operator which relaxes one entire path and all inactive nodes, thus
 382    defining num_paths neighbors.
 383    """
 384    UNACTIVELNS = _pywrapcp.Solver_UNACTIVELNS
 385    r"""
 386    Operator which relaxes all inactive nodes and one sub-chain of six
 387    consecutive arcs. That way the path can be improved by inserting
 388    inactive nodes or swapping arcs.
 389    """
 390    INCREMENT = _pywrapcp.Solver_INCREMENT
 391    r"""
 392    Operator which defines one neighbor per variable. Each neighbor tries to
 393    increment by one the value of the corresponding variable. When a new
 394    solution is found the neighborhood is rebuilt from scratch, i.e., tries
 395    to increment values in the variable order.
 396    Consider for instance variables x and y. x is incremented one by one to
 397    its max, and when it is not possible to increment x anymore, y is
 398    incremented once. If this is a solution, then next neighbor tries to
 399    increment x.
 400    """
 401    DECREMENT = _pywrapcp.Solver_DECREMENT
 402    r"""
 403    Operator which defines a neighborhood to decrement values.
 404    The behavior is the same as INCREMENT, except values are decremented
 405    instead of incremented.
 406    """
 407    SIMPLELNS = _pywrapcp.Solver_SIMPLELNS
 408    r"""
 409    Operator which defines one neighbor per variable. Each neighbor relaxes
 410    one variable.
 411    When a new solution is found the neighborhood is rebuilt from scratch.
 412    Consider for instance variables x and y. First x is relaxed and the
 413    solver is looking for the best possible solution (with only x relaxed).
 414    Then y is relaxed, and the solver is looking for a new solution.
 415    If a new solution is found, then the next variable to be relaxed is x.
 416    """
 417    GE = _pywrapcp.Solver_GE
 418    r""" Move is accepted when the current objective value >= objective.Min."""
 419    LE = _pywrapcp.Solver_LE
 420    r""" Move is accepted when the current objective value <= objective.Max."""
 421    EQ = _pywrapcp.Solver_EQ
 422    r"""
 423    Move is accepted when the current objective value is in the interval
 424    objective.Min .. objective.Max.
 425    """
 426    DELAYED_PRIORITY = _pywrapcp.Solver_DELAYED_PRIORITY
 427    r"""
 428    DELAYED_PRIORITY is the lowest priority: Demons will be processed after
 429    VAR_PRIORITY and NORMAL_PRIORITY demons.
 430    """
 431    VAR_PRIORITY = _pywrapcp.Solver_VAR_PRIORITY
 432    r""" VAR_PRIORITY is between DELAYED_PRIORITY and NORMAL_PRIORITY."""
 433    NORMAL_PRIORITY = _pywrapcp.Solver_NORMAL_PRIORITY
 434    r""" NORMAL_PRIORITY is the highest priority: Demons will be processed first."""
 435
 436    def __init__(self, *args):
 437        _pywrapcp.Solver_swiginit(self, _pywrapcp.new_Solver(*args))
 438
 439        self.__python_constraints = []
 440
 441
 442
 443    __swig_destroy__ = _pywrapcp.delete_Solver
 444
 445    def Parameters(self):
 446        r""" Stored Parameters."""
 447        return _pywrapcp.Solver_Parameters(self)
 448
 449    @staticmethod
 450    def DefaultSolverParameters():
 451        r""" Create a ConstraintSolverParameters proto with all the default values."""
 452        return _pywrapcp.Solver_DefaultSolverParameters()
 453
 454    def AddConstraint(self, c):
 455        r"""
 456        Adds the constraint 'c' to the model.
 457
 458        After calling this method, and until there is a backtrack that undoes the
 459        addition, any assignment of variables to values must satisfy the given
 460        constraint in order to be considered feasible. There are two fairly
 461        different use cases:
 462
 463        - the most common use case is modeling: the given constraint is really
 464        part of the problem that the user is trying to solve. In this use case,
 465        AddConstraint is called outside of search (i.e., with state() ==
 466        OUTSIDE_SEARCH). Most users should only use AddConstraint in this
 467        way. In this case, the constraint will belong to the model forever: it
 468        cannot not be removed by backtracking.
 469
 470        - a rarer use case is that 'c' is not a real constraint of the model. It
 471        may be a constraint generated by a branching decision (a constraint whose
 472        goal is to restrict the search space), a symmetry breaking constraint (a
 473        constraint that does restrict the search space, but in a way that cannot
 474        have an impact on the quality of the solutions in the subtree), or an
 475        inferred constraint that, while having no semantic value to the model (it
 476        does not restrict the set of solutions), is worth having because we
 477        believe it may strengthen the propagation. In these cases, it happens
 478        that the constraint is added during the search (i.e., with state() ==
 479        IN_SEARCH or state() == IN_ROOT_NODE). When a constraint is
 480        added during a search, it applies only to the subtree of the search tree
 481        rooted at the current node, and will be automatically removed by
 482        backtracking.
 483
 484        This method does not take ownership of the constraint. If the constraint
 485        has been created by any factory method (Solver::MakeXXX), it will
 486        automatically be deleted. However, power users who implement their own
 487        constraints should do: solver.AddConstraint(solver.RevAlloc(new
 488        MyConstraint(...));
 489        """
 490        return _pywrapcp.Solver_AddConstraint(self, c)
 491
 492    def Solve(self, *args):
 493        return _pywrapcp.Solver_Solve(self, *args)
 494
 495    def NewSearch(self, *args):
 496        return _pywrapcp.Solver_NewSearch(self, *args)
 497
 498    def NextSolution(self):
 499        return _pywrapcp.Solver_NextSolution(self)
 500
 501    def RestartSearch(self):
 502        return _pywrapcp.Solver_RestartSearch(self)
 503
 504    def EndSearch(self):
 505        return _pywrapcp.Solver_EndSearch(self)
 506
 507    def SolveAndCommit(self, *args):
 508        return _pywrapcp.Solver_SolveAndCommit(self, *args)
 509
 510    def CheckAssignment(self, solution):
 511        r""" Checks whether the given assignment satisfies all relevant constraints."""
 512        return _pywrapcp.Solver_CheckAssignment(self, solution)
 513
 514    def CheckConstraint(self, ct):
 515        r"""
 516        Checks whether adding this constraint will lead to an immediate
 517        failure. It will return false if the model is already inconsistent, or if
 518        adding the constraint makes it inconsistent.
 519        """
 520        return _pywrapcp.Solver_CheckConstraint(self, ct)
 521
 522    def Fail(self):
 523        r""" Abandon the current branch in the search tree. A backtrack will follow."""
 524        return _pywrapcp.Solver_Fail(self)
 525
 526    @staticmethod
 527    def MemoryUsage():
 528        r""" Current memory usage in bytes"""
 529        return _pywrapcp.Solver_MemoryUsage()
 530
 531    def WallTime(self):
 532        r"""
 533        DEPRECATED: Use Now() instead.
 534        Time elapsed, in ms since the creation of the solver.
 535        """
 536        return _pywrapcp.Solver_WallTime(self)
 537
 538    def Branches(self):
 539        r""" The number of branches explored since the creation of the solver."""
 540        return _pywrapcp.Solver_Branches(self)
 541
 542    def Solutions(self):
 543        r""" The number of solutions found since the start of the search."""
 544        return _pywrapcp.Solver_Solutions(self)
 545
 546    def Failures(self):
 547        r""" The number of failures encountered since the creation of the solver."""
 548        return _pywrapcp.Solver_Failures(self)
 549
 550    def AcceptedNeighbors(self):
 551        r""" The number of accepted neighbors."""
 552        return _pywrapcp.Solver_AcceptedNeighbors(self)
 553
 554    def Stamp(self):
 555        r"""
 556        The stamp indicates how many moves in the search tree we have performed.
 557        It is useful to detect if we need to update same lazy structures.
 558        """
 559        return _pywrapcp.Solver_Stamp(self)
 560
 561    def FailStamp(self):
 562        r""" The fail_stamp() is incremented after each backtrack."""
 563        return _pywrapcp.Solver_FailStamp(self)
 564
 565    def IntVar(self, *args):
 566        r"""
 567        *Overload 1:*
 568        MakeIntVar will create the best range based int var for the bounds given.
 569
 570        |
 571
 572        *Overload 2:*
 573        MakeIntVar will create a variable with the given sparse domain.
 574
 575        |
 576
 577        *Overload 3:*
 578        MakeIntVar will create a variable with the given sparse domain.
 579
 580        |
 581
 582        *Overload 4:*
 583        MakeIntVar will create the best range based int var for the bounds given.
 584
 585        |
 586
 587        *Overload 5:*
 588        MakeIntVar will create a variable with the given sparse domain.
 589
 590        |
 591
 592        *Overload 6:*
 593        MakeIntVar will create a variable with the given sparse domain.
 594        """
 595        return _pywrapcp.Solver_IntVar(self, *args)
 596
 597    def BoolVar(self, *args):
 598        r"""
 599        *Overload 1:*
 600        MakeBoolVar will create a variable with a {0, 1} domain.
 601
 602        |
 603
 604        *Overload 2:*
 605        MakeBoolVar will create a variable with a {0, 1} domain.
 606        """
 607        return _pywrapcp.Solver_BoolVar(self, *args)
 608
 609    def IntConst(self, *args):
 610        r"""
 611        *Overload 1:*
 612        IntConst will create a constant expression.
 613
 614        |
 615
 616        *Overload 2:*
 617        IntConst will create a constant expression.
 618        """
 619        return _pywrapcp.Solver_IntConst(self, *args)
 620
 621    def Sum(self, vars):
 622        r""" sum of all vars."""
 623        return _pywrapcp.Solver_Sum(self, vars)
 624
 625    def ScalProd(self, *args):
 626        r"""
 627        *Overload 1:*
 628        scalar product
 629
 630        |
 631
 632        *Overload 2:*
 633        scalar product
 634        """
 635        return _pywrapcp.Solver_ScalProd(self, *args)
 636
 637    def MonotonicElement(self, values, increasing, index):
 638        r"""
 639        Function based element. The constraint takes ownership of the
 640        callback.  The callback must be monotonic. It must be able to
 641        cope with any possible value in the domain of 'index'
 642        (potentially negative ones too). Furtermore, monotonicity is not
 643        checked. Thus giving a non-monotonic function, or specifying an
 644        incorrect increasing parameter will result in undefined behavior.
 645        """
 646        return _pywrapcp.Solver_MonotonicElement(self, values, increasing, index)
 647
 648    def Element(self, *args):
 649        r"""
 650        *Overload 1:*
 651        values[index]
 652
 653        |
 654
 655        *Overload 2:*
 656        values[index]
 657
 658        |
 659
 660        *Overload 3:*
 661        Function-based element. The constraint takes ownership of the
 662        callback. The callback must be able to cope with any possible
 663        value in the domain of 'index' (potentially negative ones too).
 664
 665        |
 666
 667        *Overload 4:*
 668        2D version of function-based element expression, values(expr1, expr2).
 669
 670        |
 671
 672        *Overload 5:*
 673        vars[expr]
 674        """
 675        return _pywrapcp.Solver_Element(self, *args)
 676
 677    def IndexExpression(self, vars, value):
 678        r"""
 679        Returns the expression expr such that vars[expr] == value.
 680        It assumes that vars are all different.
 681        """
 682        return _pywrapcp.Solver_IndexExpression(self, vars, value)
 683
 684    def Min(self, *args):
 685        r"""
 686        *Overload 1:*
 687        std::min(vars)
 688
 689        |
 690
 691        *Overload 2:*
 692        std::min (left, right)
 693
 694        |
 695
 696        *Overload 3:*
 697        std::min(expr, value)
 698
 699        |
 700
 701        *Overload 4:*
 702        std::min(expr, value)
 703        """
 704        return _pywrapcp.Solver_Min(self, *args)
 705
 706    def Max(self, *args):
 707        r"""
 708        *Overload 1:*
 709        std::max(vars)
 710
 711        |
 712
 713        *Overload 2:*
 714        std::max(left, right)
 715
 716        |
 717
 718        *Overload 3:*
 719        std::max(expr, value)
 720
 721        |
 722
 723        *Overload 4:*
 724        std::max(expr, value)
 725        """
 726        return _pywrapcp.Solver_Max(self, *args)
 727
 728    def ConvexPiecewiseExpr(self, expr, early_cost, early_date, late_date, late_cost):
 729        r""" Convex piecewise function."""
 730        return _pywrapcp.Solver_ConvexPiecewiseExpr(self, expr, early_cost, early_date, late_date, late_cost)
 731
 732    def SemiContinuousExpr(self, expr, fixed_charge, step):
 733        r"""
 734        Semi continuous Expression (x <= 0 -> f(x) = 0; x > 0 -> f(x) = ax + b)
 735        a >= 0 and b >= 0
 736        """
 737        return _pywrapcp.Solver_SemiContinuousExpr(self, expr, fixed_charge, step)
 738
 739    def ConditionalExpression(self, condition, expr, unperformed_value):
 740        r""" Conditional Expr condition ? expr : unperformed_value"""
 741        return _pywrapcp.Solver_ConditionalExpression(self, condition, expr, unperformed_value)
 742
 743    def TrueConstraint(self):
 744        r""" This constraint always succeeds."""
 745        return _pywrapcp.Solver_TrueConstraint(self)
 746
 747    def FalseConstraint(self, *args):
 748        return _pywrapcp.Solver_FalseConstraint(self, *args)
 749
 750    def IsEqualCstCt(self, var, value, boolvar):
 751        r""" boolvar == (var == value)"""
 752        return _pywrapcp.Solver_IsEqualCstCt(self, var, value, boolvar)
 753
 754    def IsEqualCstVar(self, var, value):
 755        r""" status var of (var == value)"""
 756        return _pywrapcp.Solver_IsEqualCstVar(self, var, value)
 757
 758    def IsEqualCt(self, v1, v2, b):
 759        r""" b == (v1 == v2)"""
 760        return _pywrapcp.Solver_IsEqualCt(self, v1, v2, b)
 761
 762    def IsEqualVar(self, v1, v2):
 763        r""" status var of (v1 == v2)"""
 764        return _pywrapcp.Solver_IsEqualVar(self, v1, v2)
 765
 766    def IsDifferentCstCt(self, var, value, boolvar):
 767        r""" boolvar == (var != value)"""
 768        return _pywrapcp.Solver_IsDifferentCstCt(self, var, value, boolvar)
 769
 770    def IsDifferentCstVar(self, var, value):
 771        r""" status var of (var != value)"""
 772        return _pywrapcp.Solver_IsDifferentCstVar(self, var, value)
 773
 774    def IsDifferentVar(self, v1, v2):
 775        r""" status var of (v1 != v2)"""
 776        return _pywrapcp.Solver_IsDifferentVar(self, v1, v2)
 777
 778    def IsDifferentCt(self, v1, v2, b):
 779        r""" b == (v1 != v2)"""
 780        return _pywrapcp.Solver_IsDifferentCt(self, v1, v2, b)
 781
 782    def IsLessOrEqualCstCt(self, var, value, boolvar):
 783        r""" boolvar == (var <= value)"""
 784        return _pywrapcp.Solver_IsLessOrEqualCstCt(self, var, value, boolvar)
 785
 786    def IsLessOrEqualCstVar(self, var, value):
 787        r""" status var of (var <= value)"""
 788        return _pywrapcp.Solver_IsLessOrEqualCstVar(self, var, value)
 789
 790    def IsLessOrEqualVar(self, left, right):
 791        r""" status var of (left <= right)"""
 792        return _pywrapcp.Solver_IsLessOrEqualVar(self, left, right)
 793
 794    def IsLessOrEqualCt(self, left, right, b):
 795        r""" b == (left <= right)"""
 796        return _pywrapcp.Solver_IsLessOrEqualCt(self, left, right, b)
 797
 798    def IsGreaterOrEqualCstCt(self, var, value, boolvar):
 799        r""" boolvar == (var >= value)"""
 800        return _pywrapcp.Solver_IsGreaterOrEqualCstCt(self, var, value, boolvar)
 801
 802    def IsGreaterOrEqualCstVar(self, var, value):
 803        r""" status var of (var >= value)"""
 804        return _pywrapcp.Solver_IsGreaterOrEqualCstVar(self, var, value)
 805
 806    def IsGreaterOrEqualVar(self, left, right):
 807        r""" status var of (left >= right)"""
 808        return _pywrapcp.Solver_IsGreaterOrEqualVar(self, left, right)
 809
 810    def IsGreaterOrEqualCt(self, left, right, b):
 811        r""" b == (left >= right)"""
 812        return _pywrapcp.Solver_IsGreaterOrEqualCt(self, left, right, b)
 813
 814    def IsGreaterCstCt(self, v, c, b):
 815        r""" b == (v > c)"""
 816        return _pywrapcp.Solver_IsGreaterCstCt(self, v, c, b)
 817
 818    def IsGreaterCstVar(self, var, value):
 819        r""" status var of (var > value)"""
 820        return _pywrapcp.Solver_IsGreaterCstVar(self, var, value)
 821
 822    def IsGreaterVar(self, left, right):
 823        r""" status var of (left > right)"""
 824        return _pywrapcp.Solver_IsGreaterVar(self, left, right)
 825
 826    def IsGreaterCt(self, left, right, b):
 827        r""" b == (left > right)"""
 828        return _pywrapcp.Solver_IsGreaterCt(self, left, right, b)
 829
 830    def IsLessCstCt(self, v, c, b):
 831        r""" b == (v < c)"""
 832        return _pywrapcp.Solver_IsLessCstCt(self, v, c, b)
 833
 834    def IsLessCstVar(self, var, value):
 835        r""" status var of (var < value)"""
 836        return _pywrapcp.Solver_IsLessCstVar(self, var, value)
 837
 838    def IsLessVar(self, left, right):
 839        r""" status var of (left < right)"""
 840        return _pywrapcp.Solver_IsLessVar(self, left, right)
 841
 842    def IsLessCt(self, left, right, b):
 843        r""" b == (left < right)"""
 844        return _pywrapcp.Solver_IsLessCt(self, left, right, b)
 845
 846    def SumLessOrEqual(self, vars, cst):
 847        r""" Variation on arrays."""
 848        return _pywrapcp.Solver_SumLessOrEqual(self, vars, cst)
 849
 850    def SumGreaterOrEqual(self, vars, cst):
 851        return _pywrapcp.Solver_SumGreaterOrEqual(self, vars, cst)
 852
 853    def SumEquality(self, *args):
 854        return _pywrapcp.Solver_SumEquality(self, *args)
 855
 856    def ScalProdEquality(self, *args):
 857        return _pywrapcp.Solver_ScalProdEquality(self, *args)
 858
 859    def ScalProdGreaterOrEqual(self, *args):
 860        return _pywrapcp.Solver_ScalProdGreaterOrEqual(self, *args)
 861
 862    def ScalProdLessOrEqual(self, *args):
 863        return _pywrapcp.Solver_ScalProdLessOrEqual(self, *args)
 864
 865    def MinEquality(self, vars, min_var):
 866        return _pywrapcp.Solver_MinEquality(self, vars, min_var)
 867
 868    def MaxEquality(self, vars, max_var):
 869        return _pywrapcp.Solver_MaxEquality(self, vars, max_var)
 870
 871    def ElementEquality(self, *args):
 872        return _pywrapcp.Solver_ElementEquality(self, *args)
 873
 874    def AbsEquality(self, var, abs_var):
 875        r""" Creates the constraint abs(var) == abs_var."""
 876        return _pywrapcp.Solver_AbsEquality(self, var, abs_var)
 877
 878    def IndexOfConstraint(self, vars, index, target):
 879        r"""
 880        This constraint is a special case of the element constraint with
 881        an array of integer variables, where the variables are all
 882        different and the index variable is constrained such that
 883        vars[index] == target.
 884        """
 885        return _pywrapcp.Solver_IndexOfConstraint(self, vars, index, target)
 886
 887    def ConstraintInitialPropagateCallback(self, ct):
 888        r"""
 889        This method is a specialized case of the MakeConstraintDemon
 890        method to call the InitiatePropagate of the constraint 'ct'.
 891        """
 892        return _pywrapcp.Solver_ConstraintInitialPropagateCallback(self, ct)
 893
 894    def DelayedConstraintInitialPropagateCallback(self, ct):
 895        r"""
 896        This method is a specialized case of the MakeConstraintDemon
 897        method to call the InitiatePropagate of the constraint 'ct' with
 898        low priority.
 899        """
 900        return _pywrapcp.Solver_DelayedConstraintInitialPropagateCallback(self, ct)
 901
 902    def ClosureDemon(self, closure):
 903        r""" Creates a demon from a closure."""
 904        return _pywrapcp.Solver_ClosureDemon(self, closure)
 905
 906    def BetweenCt(self, expr, l, u):
 907        r""" (l <= expr <= u)"""
 908        return _pywrapcp.Solver_BetweenCt(self, expr, l, u)
 909
 910    def IsBetweenCt(self, expr, l, u, b):
 911        r""" b == (l <= expr <= u)"""
 912        return _pywrapcp.Solver_IsBetweenCt(self, expr, l, u, b)
 913
 914    def IsBetweenVar(self, v, l, u):
 915        return _pywrapcp.Solver_IsBetweenVar(self, v, l, u)
 916
 917    def MemberCt(self, *args):
 918        return _pywrapcp.Solver_MemberCt(self, *args)
 919
 920    def NotMemberCt(self, *args):
 921        r"""
 922        *Overload 1:*
 923        expr not in set.
 924
 925        |
 926
 927        *Overload 2:*
 928        expr should not be in the list of forbidden intervals [start[i]..end[i]].
 929
 930        |
 931
 932        *Overload 3:*
 933        expr should not be in the list of forbidden intervals [start[i]..end[i]].
 934        """
 935        return _pywrapcp.Solver_NotMemberCt(self, *args)
 936
 937    def IsMemberCt(self, *args):
 938        return _pywrapcp.Solver_IsMemberCt(self, *args)
 939
 940    def IsMemberVar(self, *args):
 941        return _pywrapcp.Solver_IsMemberVar(self, *args)
 942
 943    def Count(self, *args):
 944        r"""
 945        *Overload 1:*
 946        |{i | vars[i] == value}| == max_count
 947
 948        |
 949
 950        *Overload 2:*
 951        |{i | vars[i] == value}| == max_count
 952        """
 953        return _pywrapcp.Solver_Count(self, *args)
 954
 955    def Distribute(self, *args):
 956        r"""
 957        *Overload 1:*
 958        Aggregated version of count:  |{i | v[i] == values[j]}| == cards[j]
 959
 960        |
 961
 962        *Overload 2:*
 963        Aggregated version of count:  |{i | v[i] == values[j]}| == cards[j]
 964
 965        |
 966
 967        *Overload 3:*
 968        Aggregated version of count:  |{i | v[i] == j}| == cards[j]
 969
 970        |
 971
 972        *Overload 4:*
 973        Aggregated version of count with bounded cardinalities:
 974        forall j in 0 .. card_size - 1: card_min <= |{i | v[i] == j}| <= card_max
 975
 976        |
 977
 978        *Overload 5:*
 979        Aggregated version of count with bounded cardinalities:
 980        forall j in 0 .. card_size - 1:
 981           card_min[j] <= |{i | v[i] == j}| <= card_max[j]
 982
 983        |
 984
 985        *Overload 6:*
 986        Aggregated version of count with bounded cardinalities:
 987        forall j in 0 .. card_size - 1:
 988           card_min[j] <= |{i | v[i] == j}| <= card_max[j]
 989
 990        |
 991
 992        *Overload 7:*
 993        Aggregated version of count with bounded cardinalities:
 994        forall j in 0 .. card_size - 1:
 995           card_min[j] <= |{i | v[i] == values[j]}| <= card_max[j]
 996
 997        |
 998
 999        *Overload 8:*
1000        Aggregated version of count with bounded cardinalities:
1001        forall j in 0 .. card_size - 1:
1002           card_min[j] <= |{i | v[i] == values[j]}| <= card_max[j]
1003        """
1004        return _pywrapcp.Solver_Distribute(self, *args)
1005
1006    def Deviation(self, vars, deviation_var, total_sum):
1007        r"""
1008        Deviation constraint:
1009        sum_i |n * vars[i] - total_sum| <= deviation_var and
1010        sum_i vars[i] == total_sum
1011        n = #vars
1012        """
1013        return _pywrapcp.Solver_Deviation(self, vars, deviation_var, total_sum)
1014
1015    def AllDifferent(self, *args):
1016        r"""
1017        *Overload 1:*
1018        All variables are pairwise different. This corresponds to the
1019        stronger version of the propagation algorithm.
1020
1021        |
1022
1023        *Overload 2:*
1024        All variables are pairwise different.  If 'stronger_propagation'
1025        is true, stronger, and potentially slower propagation will
1026        occur. This API will be deprecated in the future.
1027        """
1028        return _pywrapcp.Solver_AllDifferent(self, *args)
1029
1030    def AllDifferentExcept(self, vars, escape_value):
1031        r"""
1032        All variables are pairwise different, unless they are assigned to
1033        the escape value.
1034        """
1035        return _pywrapcp.Solver_AllDifferentExcept(self, vars, escape_value)
1036
1037    def SortingConstraint(self, vars, sorted):
1038        r"""
1039        Creates a constraint binding the arrays of variables "vars" and
1040        "sorted_vars": sorted_vars[0] must be equal to the minimum of all
1041        variables in vars, and so on: the value of sorted_vars[i] must be
1042        equal to the i-th value of variables invars.
1043
1044        This constraint propagates in both directions: from "vars" to
1045        "sorted_vars" and vice-versa.
1046
1047        Behind the scenes, this constraint maintains that:
1048          - sorted is always increasing.
1049          - whatever the values of vars, there exists a permutation that
1050            injects its values into the sorted variables.
1051
1052        For more info, please have a look at:
1053          https://mpi-inf.mpg.de/~mehlhorn/ftp/Mehlhorn-Thiel.pdf
1054        """
1055        return _pywrapcp.Solver_SortingConstraint(self, vars, sorted)
1056
1057    def LexicalLess(self, left, right):
1058        r"""
1059        Creates a constraint that enforces that left is lexicographically less
1060        than right.
1061        """
1062        return _pywrapcp.Solver_LexicalLess(self, left, right)
1063
1064    def LexicalLessOrEqual(self, left, right):
1065        r"""
1066        Creates a constraint that enforces that left is lexicographically less
1067        than or equal to right.
1068        """
1069        return _pywrapcp.Solver_LexicalLessOrEqual(self, left, right)
1070
1071    def InversePermutationConstraint(self, left, right):
1072        r"""
1073        Creates a constraint that enforces that 'left' and 'right' both
1074        represent permutations of [0..left.size()-1], and that 'right' is
1075        the inverse permutation of 'left', i.e. for all i in
1076        [0..left.size()-1], right[left[i]] = i.
1077        """
1078        return _pywrapcp.Solver_InversePermutationConstraint(self, left, right)
1079
1080    def NullIntersect(self, first_vars, second_vars):
1081        r"""
1082        Creates a constraint that states that all variables in the first
1083        vector are different from all variables in the second
1084        group. Thus the set of values in the first vector does not
1085        intersect with the set of values in the second vector.
1086        """
1087        return _pywrapcp.Solver_NullIntersect(self, first_vars, second_vars)
1088
1089    def NullIntersectExcept(self, first_vars, second_vars, escape_value):
1090        r"""
1091        Creates a constraint that states that all variables in the first
1092        vector are different from all variables from the second group,
1093        unless they are assigned to the escape value. Thus the set of
1094        values in the first vector minus the escape value does not
1095        intersect with the set of values in the second vector.
1096        """
1097        return _pywrapcp.Solver_NullIntersectExcept(self, first_vars, second_vars, escape_value)
1098
1099    def Circuit(self, nexts):
1100        r""" Force the "nexts" variable to create a complete Hamiltonian path."""
1101        return _pywrapcp.Solver_Circuit(self, nexts)
1102
1103    def SubCircuit(self, nexts):
1104        r"""
1105        Force the "nexts" variable to create a complete Hamiltonian path
1106        for those that do not loop upon themselves.
1107        """
1108        return _pywrapcp.Solver_SubCircuit(self, nexts)
1109
1110    def DelayedPathCumul(self, nexts, active, cumuls, transits):
1111        r"""
1112        Delayed version of the same constraint: propagation on the nexts variables
1113        is delayed until all constraints have propagated.
1114        """
1115        return _pywrapcp.Solver_DelayedPathCumul(self, nexts, active, cumuls, transits)
1116
1117    def PathCumul(self, *args):
1118        r"""
1119        *Overload 1:*
1120        Creates a constraint which accumulates values along a path such that:
1121        cumuls[next[i]] = cumuls[i] + transits[i].
1122        Active variables indicate if the corresponding next variable is active;
1123        this could be useful to model unperformed nodes in a routing problem.
1124
1125        |
1126
1127        *Overload 2:*
1128        Creates a constraint which accumulates values along a path such that:
1129        cumuls[next[i]] = cumuls[i] + transit_evaluator(i, next[i]).
1130        Active variables indicate if the corresponding next variable is active;
1131        this could be useful to model unperformed nodes in a routing problem.
1132        Ownership of transit_evaluator is taken and it must be a repeatable
1133        callback.
1134
1135        |
1136
1137        *Overload 3:*
1138        Creates a constraint which accumulates values along a path such that:
1139        cumuls[next[i]] = cumuls[i] + transit_evaluator(i, next[i]) + slacks[i].
1140        Active variables indicate if the corresponding next variable is active;
1141        this could be useful to model unperformed nodes in a routing problem.
1142        Ownership of transit_evaluator is taken and it must be a repeatable
1143        callback.
1144        """
1145        return _pywrapcp.Solver_PathCumul(self, *args)
1146
1147    def AllowedAssignments(self, *args):
1148        r"""
1149        *Overload 1:*
1150        This method creates a constraint where the graph of the relation
1151        between the variables is given in extension. There are 'arity'
1152        variables involved in the relation and the graph is given by a
1153        integer tuple set.
1154
1155        |
1156
1157        *Overload 2:*
1158        Compatibility layer for Python API.
1159        """
1160        return _pywrapcp.Solver_AllowedAssignments(self, *args)
1161
1162    def TransitionConstraint(self, *args):
1163        return _pywrapcp.Solver_TransitionConstraint(self, *args)
1164
1165    def NonOverlappingBoxesConstraint(self, *args):
1166        return _pywrapcp.Solver_NonOverlappingBoxesConstraint(self, *args)
1167
1168    def Pack(self, vars, number_of_bins):
1169        r"""
1170        This constraint packs all variables onto 'number_of_bins'
1171        variables.  For any given variable, a value of 'number_of_bins'
1172        indicates that the variable is not assigned to any bin.
1173        Dimensions, i.e., cumulative constraints on this packing, can be
1174        added directly from the pack class.
1175        """
1176        return _pywrapcp.Solver_Pack(self, vars, number_of_bins)
1177
1178    def FixedDurationIntervalVar(self, *args):
1179        r"""
1180        *Overload 1:*
1181        Creates an interval var with a fixed duration. The duration must
1182        be greater than 0. If optional is true, then the interval can be
1183        performed or unperformed. If optional is false, then the interval
1184        is always performed.
1185
1186        |
1187
1188        *Overload 2:*
1189        Creates a performed interval var with a fixed duration. The duration must
1190        be greater than 0.
1191
1192        |
1193
1194        *Overload 3:*
1195        Creates an interval var with a fixed duration, and performed_variable.
1196        The duration must be greater than 0.
1197        """
1198        return _pywrapcp.Solver_FixedDurationIntervalVar(self, *args)
1199
1200    def FixedInterval(self, start, duration, name):
1201        r""" Creates a fixed and performed interval."""
1202        return _pywrapcp.Solver_FixedInterval(self, start, duration, name)
1203
1204    def IntervalVar(self, start_min, start_max, duration_min, duration_max, end_min, end_max, optional, name):
1205        r"""
1206        Creates an interval var by specifying the bounds on start,
1207        duration, and end.
1208        """
1209        return _pywrapcp.Solver_IntervalVar(self, start_min, start_max, duration_min, duration_max, end_min, end_max, optional, name)
1210
1211    def MirrorInterval(self, interval_var):
1212        r"""
1213        Creates an interval var that is the mirror image of the given one, that
1214        is, the interval var obtained by reversing the axis.
1215        """
1216        return _pywrapcp.Solver_MirrorInterval(self, interval_var)
1217
1218    def FixedDurationStartSyncedOnStartIntervalVar(self, interval_var, duration, offset):
1219        r"""
1220        Creates an interval var with a fixed duration whose start is
1221        synchronized with the start of another interval, with a given
1222        offset. The performed status is also in sync with the performed
1223        status of the given interval variable.
1224        """
1225        return _pywrapcp.Solver_FixedDurationStartSyncedOnStartIntervalVar(self, interval_var, duration, offset)
1226
1227    def FixedDurationStartSyncedOnEndIntervalVar(self, interval_var, duration, offset):
1228        r"""
1229        Creates an interval var with a fixed duration whose start is
1230        synchronized with the end of another interval, with a given
1231        offset. The performed status is also in sync with the performed
1232        status of the given interval variable.
1233        """
1234        return _pywrapcp.Solver_FixedDurationStartSyncedOnEndIntervalVar(self, interval_var, duration, offset)
1235
1236    def FixedDurationEndSyncedOnStartIntervalVar(self, interval_var, duration, offset):
1237        r"""
1238        Creates an interval var with a fixed duration whose end is
1239        synchronized with the start of another interval, with a given
1240        offset. The performed status is also in sync with the performed
1241        status of the given interval variable.
1242        """
1243        return _pywrapcp.Solver_FixedDurationEndSyncedOnStartIntervalVar(self, interval_var, duration, offset)
1244
1245    def FixedDurationEndSyncedOnEndIntervalVar(self, interval_var, duration, offset):
1246        r"""
1247        Creates an interval var with a fixed duration whose end is
1248        synchronized with the end of another interval, with a given
1249        offset. The performed status is also in sync with the performed
1250        status of the given interval variable.
1251        """
1252        return _pywrapcp.Solver_FixedDurationEndSyncedOnEndIntervalVar(self, interval_var, duration, offset)
1253
1254    def IntervalRelaxedMin(self, interval_var):
1255        r"""
1256         Creates and returns an interval variable that wraps around the given one,
1257         relaxing the min start and end. Relaxing means making unbounded when
1258         optional. If the variable is non-optional, this method returns
1259         interval_var.
1260
1261         More precisely, such an interval variable behaves as follows:
1262        When the underlying must be performed, the returned interval variable
1263             behaves exactly as the underlying;
1264        When the underlying may or may not be performed, the returned interval
1265             variable behaves like the underlying, except that it is unbounded on
1266             the min side;
1267        When the underlying cannot be performed, the returned interval variable
1268             is of duration 0 and must be performed in an interval unbounded on
1269             both sides.
1270
1271         This is very useful to implement propagators that may only modify
1272         the start max or end max.
1273        """
1274        return _pywrapcp.Solver_IntervalRelaxedMin(self, interval_var)
1275
1276    def IntervalRelaxedMax(self, interval_var):
1277        r"""
1278         Creates and returns an interval variable that wraps around the given one,
1279         relaxing the max start and end. Relaxing means making unbounded when
1280         optional. If the variable is non optional, this method returns
1281         interval_var.
1282
1283         More precisely, such an interval variable behaves as follows:
1284        When the underlying must be performed, the returned interval variable
1285             behaves exactly as the underlying;
1286        When the underlying may or may not be performed, the returned interval
1287             variable behaves like the underlying, except that it is unbounded on
1288             the max side;
1289        When the underlying cannot be performed, the returned interval variable
1290             is of duration 0 and must be performed in an interval unbounded on
1291             both sides.
1292
1293         This is very useful for implementing propagators that may only modify
1294         the start min or end min.
1295        """
1296        return _pywrapcp.Solver_IntervalRelaxedMax(self, interval_var)
1297
1298    def TemporalDisjunction(self, *args):
1299        r"""
1300        *Overload 1:*
1301        This constraint implements a temporal disjunction between two
1302        interval vars t1 and t2. 'alt' indicates which alternative was
1303        chosen (alt == 0 is equivalent to t1 before t2).
1304
1305        |
1306
1307        *Overload 2:*
1308        This constraint implements a temporal disjunction between two
1309        interval vars.
1310        """
1311        return _pywrapcp.Solver_TemporalDisjunction(self, *args)
1312
1313    def DisjunctiveConstraint(self, intervals, name):
1314        r"""
1315        This constraint forces all interval vars into an non-overlapping
1316        sequence. Intervals with zero duration can be scheduled anywhere.
1317        """
1318        return _pywrapcp.Solver_DisjunctiveConstraint(self, intervals, name)
1319
1320    def Cumulative(self, *args):
1321        r"""
1322        *Overload 1:*
1323        This constraint forces that, for any integer t, the sum of the demands
1324        corresponding to an interval containing t does not exceed the given
1325        capacity.
1326
1327        Intervals and demands should be vectors of equal size.
1328
1329        Demands should only contain non-negative values. Zero values are
1330        supported, and the corresponding intervals are filtered out, as they
1331        neither impact nor are impacted by this constraint.
1332
1333        |
1334
1335        *Overload 2:*
1336        This constraint forces that, for any integer t, the sum of the demands
1337        corresponding to an interval containing t does not exceed the given
1338        capacity.
1339
1340        Intervals and demands should be vectors of equal size.
1341
1342        Demands should only contain non-negative values. Zero values are
1343        supported, and the corresponding intervals are filtered out, as they
1344        neither impact nor are impacted by this constraint.
1345
1346        |
1347
1348        *Overload 3:*
1349        This constraint forces that, for any integer t, the sum of the demands
1350        corresponding to an interval containing t does not exceed the given
1351        capacity.
1352
1353        Intervals and demands should be vectors of equal size.
1354
1355        Demands should only contain non-negative values. Zero values are
1356        supported, and the corresponding intervals are filtered out, as they
1357        neither impact nor are impacted by this constraint.
1358
1359        |
1360
1361        *Overload 4:*
1362        This constraint enforces that, for any integer t, the sum of the demands
1363        corresponding to an interval containing t does not exceed the given
1364        capacity.
1365
1366        Intervals and demands should be vectors of equal size.
1367
1368        Demands should only contain non-negative values. Zero values are
1369        supported, and the corresponding intervals are filtered out, as they
1370        neither impact nor are impacted by this constraint.
1371
1372        |
1373
1374        *Overload 5:*
1375        This constraint enforces that, for any integer t, the sum of demands
1376        corresponding to an interval containing t does not exceed the given
1377        capacity.
1378
1379        Intervals and demands should be vectors of equal size.
1380
1381        Demands should be positive.
1382
1383        |
1384
1385        *Overload 6:*
1386        This constraint enforces that, for any integer t, the sum of demands
1387        corresponding to an interval containing t does not exceed the given
1388        capacity.
1389
1390        Intervals and demands should be vectors of equal size.
1391
1392        Demands should be positive.
1393        """
1394        return _pywrapcp.Solver_Cumulative(self, *args)
1395
1396    def Cover(self, vars, target_var):
1397        r"""
1398        This constraint states that the target_var is the convex hull of
1399        the intervals. If none of the interval variables is performed,
1400        then the target var is unperformed too. Also, if the target
1401        variable is unperformed, then all the intervals variables are
1402        unperformed too.
1403        """
1404        return _pywrapcp.Solver_Cover(self, vars, target_var)
1405
1406    def Assignment(self, *args):
1407        r"""
1408        *Overload 1:*
1409        This method creates an empty assignment.
1410
1411        |
1412
1413        *Overload 2:*
1414        This method creates an assignment which is a copy of 'a'.
1415        """
1416        return _pywrapcp.Solver_Assignment(self, *args)
1417
1418    def FirstSolutionCollector(self, *args):
1419        r"""
1420        *Overload 1:*
1421        Collect the first solution of the search.
1422
1423        |
1424
1425        *Overload 2:*
1426        Collect the first solution of the search. The variables will need to
1427        be added later.
1428        """
1429        return _pywrapcp.Solver_FirstSolutionCollector(self, *args)
1430
1431    def LastSolutionCollector(self, *args):
1432        r"""
1433        *Overload 1:*
1434        Collect the last solution of the search.
1435
1436        |
1437
1438        *Overload 2:*
1439        Collect the last solution of the search. The variables will need to
1440        be added later.
1441        """
1442        return _pywrapcp.Solver_LastSolutionCollector(self, *args)
1443
1444    def BestValueSolutionCollector(self, *args):
1445        r"""
1446        *Overload 1:*
1447        Collect the solution corresponding to the optimal value of the objective
1448        of 'assignment'; if 'assignment' does not have an objective no solution is
1449        collected. This collector only collects one solution corresponding to the
1450        best objective value (the first one found).
1451
1452        |
1453
1454        *Overload 2:*
1455        Collect the solution corresponding to the optimal value of the
1456        objective of 'assignment'; if 'assignment' does not have an objective no
1457        solution is collected. This collector only collects one solution
1458        corresponding to the best objective value (the first one
1459        found). The variables will need to be added later.
1460        """
1461        return _pywrapcp.Solver_BestValueSolutionCollector(self, *args)
1462
1463    def AllSolutionCollector(self, *args):
1464        r"""
1465        *Overload 1:*
1466        Collect all solutions of the search.
1467
1468        |
1469
1470        *Overload 2:*
1471        Collect all solutions of the search. The variables will need to
1472        be added later.
1473        """
1474        return _pywrapcp.Solver_AllSolutionCollector(self, *args)
1475
1476    def Minimize(self, v, step):
1477        r""" Creates a minimization objective."""
1478        return _pywrapcp.Solver_Minimize(self, v, step)
1479
1480    def Maximize(self, v, step):
1481        r""" Creates a maximization objective."""
1482        return _pywrapcp.Solver_Maximize(self, v, step)
1483
1484    def Optimize(self, maximize, v, step):
1485        r""" Creates a objective with a given sense (true = maximization)."""
1486        return _pywrapcp.Solver_Optimize(self, maximize, v, step)
1487
1488    def WeightedMinimize(self, *args):
1489        r"""
1490        *Overload 1:*
1491        Creates a minimization weighted objective. The actual objective is
1492        scalar_prod(sub_objectives, weights).
1493
1494        |
1495
1496        *Overload 2:*
1497        Creates a minimization weighted objective. The actual objective is
1498        scalar_prod(sub_objectives, weights).
1499        """
1500        return _pywrapcp.Solver_WeightedMinimize(self, *args)
1501
1502    def WeightedMaximize(self, *args):
1503        r"""
1504        *Overload 1:*
1505        Creates a maximization weigthed objective.
1506
1507        |
1508
1509        *Overload 2:*
1510        Creates a maximization weigthed objective.
1511        """
1512        return _pywrapcp.Solver_WeightedMaximize(self, *args)
1513
1514    def WeightedOptimize(self, *args):
1515        r"""
1516        *Overload 1:*
1517        Creates a weighted objective with a given sense (true = maximization).
1518
1519        |
1520
1521        *Overload 2:*
1522        Creates a weighted objective with a given sense (true = maximization).
1523        """
1524        return _pywrapcp.Solver_WeightedOptimize(self, *args)
1525
1526    def TabuSearch(self, maximize, v, step, vars, keep_tenure, forbid_tenure, tabu_factor):
1527        r"""
1528        MetaHeuristics which try to get the search out of local optima.
1529        Creates a Tabu Search monitor.
1530        In the context of local search the behavior is similar to MakeOptimize(),
1531        creating an objective in a given sense. The behavior differs once a local
1532        optimum is reached: thereafter solutions which degrade the value of the
1533        objective are allowed if they are not "tabu". A solution is "tabu" if it
1534        doesn't respect the following rules:
1535        - improving the best solution found so far
1536        - variables in the "keep" list must keep their value, variables in the
1537        "forbid" list must not take the value they have in the list.
1538        Variables with new values enter the tabu lists after each new solution
1539        found and leave the lists after a given number of iterations (called
1540        tenure). Only the variables passed to the method can enter the lists.
1541        The tabu criterion is softened by the tabu factor which gives the number
1542        of "tabu" violations which is tolerated; a factor of 1 means no violations
1543        allowed; a factor of 0 means all violations are allowed.
1544        """
1545        return _pywrapcp.Solver_TabuSearch(self, maximize, v, step, vars, keep_tenure, forbid_tenure, tabu_factor)
1546
1547    def SimulatedAnnealing(self, maximize, v, step, initial_temperature):
1548        r""" Creates a Simulated Annealing monitor."""
1549        return _pywrapcp.Solver_SimulatedAnnealing(self, maximize, v, step, initial_temperature)
1550
1551    def LubyRestart(self, scale_factor):
1552        r"""
1553        This search monitor will restart the search periodically.
1554        At the iteration n, it will restart after scale_factor * Luby(n) failures
1555        where Luby is the Luby Strategy (i.e. 1 1 2 1 1 2 4 1 1 2 1 1 2 4 8...).
1556        """
1557        return _pywrapcp.Solver_LubyRestart(self, scale_factor)
1558
1559    def ConstantRestart(self, frequency):
1560        r"""
1561        This search monitor will restart the search periodically after 'frequency'
1562        failures.
1563        """
1564        return _pywrapcp.Solver_ConstantRestart(self, frequency)
1565
1566    def TimeLimit(self, *args):
1567        return _pywrapcp.Solver_TimeLimit(self, *args)
1568
1569    def BranchesLimit(self, branches):
1570        r"""
1571        Creates a search limit that constrains the number of branches
1572        explored in the search tree.
1573        """
1574        return _pywrapcp.Solver_BranchesLimit(self, branches)
1575
1576    def FailuresLimit(self, failures):
1577        r"""
1578        Creates a search limit that constrains the number of failures
1579        that can happen when exploring the search tree.
1580        """
1581        return _pywrapcp.Solver_FailuresLimit(self, failures)
1582
1583    def SolutionsLimit(self, solutions):
1584        r"""
1585        Creates a search limit that constrains the number of solutions found
1586        during the search.
1587        """
1588        return _pywrapcp.Solver_SolutionsLimit(self, solutions)
1589
1590    def Limit(self, *args):
1591        r"""
1592        *Overload 1:*
1593        Limits the search with the 'time', 'branches', 'failures' and
1594        'solutions' limits. 'smart_time_check' reduces the calls to the wall
1595
1596        |
1597
1598        *Overload 2:*
1599        Creates a search limit from its protobuf description
1600
1601        |
1602
1603        *Overload 3:*
1604        Creates a search limit that is reached when either of the underlying limit
1605        is reached. That is, the returned limit is more stringent than both
1606        argument limits.
1607        """
1608        return _pywrapcp.Solver_Limit(self, *args)
1609
1610    def CustomLimit(self, limiter):
1611        r"""
1612        Callback-based search limit. Search stops when limiter returns true; if
1613        this happens at a leaf the corresponding solution will be rejected.
1614        """
1615        return _pywrapcp.Solver_CustomLimit(self, limiter)
1616
1617    def SearchLog(self, *args):
1618        return _pywrapcp.Solver_SearchLog(self, *args)
1619
1620    def SearchTrace(self, prefix):
1621        r"""
1622        Creates a search monitor that will trace precisely the behavior of the
1623        search. Use this only for low level debugging.
1624        """
1625        return _pywrapcp.Solver_SearchTrace(self, prefix)
1626
1627    def PrintModelVisitor(self):
1628        r""" Prints the model."""
1629        return _pywrapcp.Solver_PrintModelVisitor(self)
1630
1631    def StatisticsModelVisitor(self):
1632        r""" Displays some nice statistics on the model."""
1633        return _pywrapcp.Solver_StatisticsModelVisitor(self)
1634
1635    def AssignVariableValue(self, var, val):
1636        r""" Decisions."""
1637        return _pywrapcp.Solver_AssignVariableValue(self, var, val)
1638
1639    def VariableLessOrEqualValue(self, var, value):
1640        return _pywrapcp.Solver_VariableLessOrEqualValue(self, var, value)
1641
1642    def VariableGreaterOrEqualValue(self, var, value):
1643        return _pywrapcp.Solver_VariableGreaterOrEqualValue(self, var, value)
1644
1645    def SplitVariableDomain(self, var, val, start_with_lower_half):
1646        return _pywrapcp.Solver_SplitVariableDomain(self, var, val, start_with_lower_half)
1647
1648    def AssignVariableValueOrFail(self, var, value):
1649        return _pywrapcp.Solver_AssignVariableValueOrFail(self, var, value)
1650
1651    def AssignVariablesValues(self, vars, values):
1652        return _pywrapcp.Solver_AssignVariablesValues(self, vars, values)
1653
1654    def FailDecision(self):
1655        return _pywrapcp.Solver_FailDecision(self)
1656
1657    def Decision(self, apply, refute):
1658        return _pywrapcp.Solver_Decision(self, apply, refute)
1659
1660    def Compose(self, dbs):
1661        return _pywrapcp.Solver_Compose(self, dbs)
1662
1663    def Try(self, dbs):
1664        return _pywrapcp.Solver_Try(self, dbs)
1665
1666    def DefaultPhase(self, *args):
1667        return _pywrapcp.Solver_DefaultPhase(self, *args)
1668
1669    def ScheduleOrPostpone(self, var, est, marker):
1670        r"""
1671        Returns a decision that tries to schedule a task at a given time.
1672        On the Apply branch, it will set that interval var as performed and set
1673        its start to 'est'. On the Refute branch, it will just update the
1674        'marker' to 'est' + 1. This decision is used in the
1675        INTERVAL_SET_TIMES_FORWARD strategy.
1676        """
1677        return _pywrapcp.Solver_ScheduleOrPostpone(self, var, est, marker)
1678
1679    def ScheduleOrExpedite(self, var, est, marker):
1680        r"""
1681        Returns a decision that tries to schedule a task at a given time.
1682        On the Apply branch, it will set that interval var as performed and set
1683        its end to 'est'. On the Refute branch, it will just update the
1684        'marker' to 'est' - 1. This decision is used in the
1685        INTERVAL_SET_TIMES_BACKWARD strategy.
1686        """
1687        return _pywrapcp.Solver_ScheduleOrExpedite(self, var, est, marker)
1688
1689    def RankFirstInterval(self, sequence, index):
1690        r"""
1691        Returns a decision that tries to rank first the ith interval var
1692        in the sequence variable.
1693        """
1694        return _pywrapcp.Solver_RankFirstInterval(self, sequence, index)
1695
1696    def RankLastInterval(self, sequence, index):
1697        r"""
1698        Returns a decision that tries to rank last the ith interval var
1699        in the sequence variable.
1700        """
1701        return _pywrapcp.Solver_RankLastInterval(self, sequence, index)
1702
1703    def Phase(self, *args):
1704        return _pywrapcp.Solver_Phase(self, *args)
1705
1706    def DecisionBuilderFromAssignment(self, assignment, db, vars):
1707        r"""
1708        Returns a decision builder for which the left-most leaf corresponds
1709        to assignment, the rest of the tree being explored using 'db'.
1710        """
1711        return _pywrapcp.Solver_DecisionBuilderFromAssignment(self, assignment, db, vars)
1712
1713    def ConstraintAdder(self, ct):
1714        r"""
1715        Returns a decision builder that will add the given constraint to
1716        the model.
1717        """
1718        return _pywrapcp.Solver_ConstraintAdder(self, ct)
1719
1720    def SolveOnce(self, db, monitors):
1721        return _pywrapcp.Solver_SolveOnce(self, db, monitors)
1722
1723    def NestedOptimize(self, *args):
1724        return _pywrapcp.Solver_NestedOptimize(self, *args)
1725
1726    def RestoreAssignment(self, assignment):
1727        r"""
1728        Returns a DecisionBuilder which restores an Assignment
1729        (calls void Assignment::Restore())
1730        """
1731        return _pywrapcp.Solver_RestoreAssignment(self, assignment)
1732
1733    def StoreAssignment(self, assignment):
1734        r"""
1735        Returns a DecisionBuilder which stores an Assignment
1736        (calls void Assignment::Store())
1737        """
1738        return _pywrapcp.Solver_StoreAssignment(self, assignment)
1739
1740    def Operator(self, *args):
1741        return _pywrapcp.Solver_Operator(self, *args)
1742
1743    def RandomLnsOperator(self, *args):
1744        return _pywrapcp.Solver_RandomLnsOperator(self, *args)
1745
1746    def MoveTowardTargetOperator(self, *args):
1747        r"""
1748        *Overload 1:*
1749        Creates a local search operator that tries to move the assignment of some
1750        variables toward a target. The target is given as an Assignment. This
1751        operator generates neighbors in which the only difference compared to the
1752        current state is that one variable that belongs to the target assignment
1753        is set to its target value.
1754
1755        |
1756
1757        *Overload 2:*
1758        Creates a local search operator that tries to move the assignment of some
1759        variables toward a target. The target is given either as two vectors: a
1760        vector of variables and a vector of associated target values. The two
1761        vectors should be of the same length. This operator generates neighbors in
1762        which the only difference compared to the current state is that one
1763        variable that belongs to the given vector is set to its target value.
1764        """
1765        return _pywrapcp.Solver_MoveTowardTargetOperator(self, *args)
1766
1767    def ConcatenateOperators(self, *args):
1768        return _pywrapcp.Solver_ConcatenateOperators(self, *args)
1769
1770    def RandomConcatenateOperators(self, *args):
1771        r"""
1772        *Overload 1:*
1773        Randomized version of local search concatenator; calls a random operator
1774        at each call to MakeNextNeighbor().
1775
1776        |
1777
1778        *Overload 2:*
1779        Randomized version of local search concatenator; calls a random operator
1780        at each call to MakeNextNeighbor(). The provided seed is used to
1781        initialize the random number generator.
1782        """
1783        return _pywrapcp.Solver_RandomConcatenateOperators(self, *args)
1784
1785    def NeighborhoodLimit(self, op, limit):
1786        r"""
1787        Creates a local search operator that wraps another local search
1788        operator and limits the number of neighbors explored (i.e., calls
1789        to MakeNextNeighbor from the current solution (between two calls
1790        to Start()). When this limit is reached, MakeNextNeighbor()
1791        returns false. The counter is cleared when Start() is called.
1792        """
1793        return _pywrapcp.Solver_NeighborhoodLimit(self, op, limit)
1794
1795    def LocalSearchPhase(self, *args):
1796        return _pywrapcp.Solver_LocalSearchPhase(self, *args)
1797
1798    def LocalSearchPhaseParameters(self, *args):
1799        return _pywrapcp.Solver_LocalSearchPhaseParameters(self, *args)
1800
1801    def SearchDepth(self):
1802        r"""
1803        Gets the search depth of the current active search. Returns -1 if
1804        there is no active search opened.
1805        """
1806        return _pywrapcp.Solver_SearchDepth(self)
1807
1808    def SearchLeftDepth(self):
1809        r"""
1810        Gets the search left depth of the current active search. Returns -1 if
1811        there is no active search opened.
1812        """
1813        return _pywrapcp.Solver_SearchLeftDepth(self)
1814
1815    def SolveDepth(self):
1816        r"""
1817        Gets the number of nested searches. It returns 0 outside search,
1818        1 during the top level search, 2 or more in case of nested searches.
1819        """
1820        return _pywrapcp.Solver_SolveDepth(self)
1821
1822    def Rand64(self, size):
1823        r""" Returns a random value between 0 and 'size' - 1;"""
1824        return _pywrapcp.Solver_Rand64(self, size)
1825
1826    def Rand32(self, size):
1827        r""" Returns a random value between 0 and 'size' - 1;"""
1828        return _pywrapcp.Solver_Rand32(self, size)
1829
1830    def ReSeed(self, seed):
1831        r""" Reseed the solver random generator."""
1832        return _pywrapcp.Solver_ReSeed(self, seed)
1833
1834    def LocalSearchProfile(self):
1835        r""" Returns local search profiling information in a human readable format."""
1836        return _pywrapcp.Solver_LocalSearchProfile(self)
1837
1838    def Constraints(self):
1839        r"""
1840        Counts the number of constraints that have been added
1841        to the solver before the search.
1842        """
1843        return _pywrapcp.Solver_Constraints(self)
1844
1845    def Accept(self, visitor):
1846        r""" Accepts the given model visitor."""
1847        return _pywrapcp.Solver_Accept(self, visitor)
1848
1849    def FinishCurrentSearch(self):
1850        r""" Tells the solver to kill or restart the current search."""
1851        return _pywrapcp.Solver_FinishCurrentSearch(self)
1852
1853    def RestartCurrentSearch(self):
1854        return _pywrapcp.Solver_RestartCurrentSearch(self)
1855
1856    def ShouldFail(self):
1857        r"""
1858        These methods are only useful for the SWIG wrappers, which need a way
1859        to externally cause the Solver to fail.
1860        """
1861        return _pywrapcp.Solver_ShouldFail(self)
1862
1863    def __str__(self):
1864        return _pywrapcp.Solver___str__(self)
1865
1866    def Add(self, ct):
1867      if isinstance(ct, PyConstraint):
1868        self.__python_constraints.append(ct)
1869      self.AddConstraint(ct)
1870
1871
1872    def TreeNoCycle(self, nexts, active, callback=0):
1873        return _pywrapcp.Solver_TreeNoCycle(self, nexts, active, callback)
1874
1875    def SearchLogWithCallback(self, period, callback):
1876        return _pywrapcp.Solver_SearchLogWithCallback(self, period, callback)
1877
1878    def ElementFunction(self, values, index):
1879        return _pywrapcp.Solver_ElementFunction(self, values, index)
1880
1881    def VarEvalValStrPhase(self, vars, var_evaluator, val_str):
1882        return _pywrapcp.Solver_VarEvalValStrPhase(self, vars, var_evaluator, val_str)
1883
1884    def VarStrValEvalPhase(self, vars, var_str, val_eval):
1885        return _pywrapcp.Solver_VarStrValEvalPhase(self, vars, var_str, val_eval)
1886
1887    def VarEvalValEvalPhase(self, vars, var_eval, val_eval):
1888        return _pywrapcp.Solver_VarEvalValEvalPhase(self, vars, var_eval, val_eval)
1889
1890    def VarStrValEvalTieBreakPhase(self, vars, var_str, val_eval, tie_breaker):
1891        return _pywrapcp.Solver_VarStrValEvalTieBreakPhase(self, vars, var_str, val_eval, tie_breaker)
1892
1893    def VarEvalValEvalTieBreakPhase(self, vars, var_eval, val_eval, tie_breaker):
1894        return _pywrapcp.Solver_VarEvalValEvalTieBreakPhase(self, vars, var_eval, val_eval, tie_breaker)
1895
1896    def EvalEvalStrPhase(self, vars, evaluator, str):
1897        return _pywrapcp.Solver_EvalEvalStrPhase(self, vars, evaluator, str)
1898
1899    def EvalEvalStrTieBreakPhase(self, vars, evaluator, tie_breaker, str):
1900        return _pywrapcp.Solver_EvalEvalStrTieBreakPhase(self, vars, evaluator, tie_breaker, str)
1901
1902    def GuidedLocalSearch(self, *args):
1903        return _pywrapcp.Solver_GuidedLocalSearch(self, *args)
1904
1905    def SumObjectiveFilter(self, vars, values, filter_enum):
1906        return _pywrapcp.Solver_SumObjectiveFilter(self, vars, values, filter_enum)

Solver Class

A solver represents the main computation engine. It implements the entire range of Constraint Programming protocols:

  • Reversibility
  • Propagation
  • Search

Usually, Constraint Programming code consists of

  • the creation of the Solver,
  • the creation of the decision variables of the model,
  • the creation of the constraints of the model and their addition to the solver() through the AddConstraint() method,
  • the creation of the main DecisionBuilder class,
  • the launch of the solve() method with the decision builder.

For the time being, Solver is neither MT_SAFE nor MT_HOT.

Solver(*args)
436    def __init__(self, *args):
437        _pywrapcp.Solver_swiginit(self, _pywrapcp.new_Solver(*args))
438
439        self.__python_constraints = []
thisown

The membership flag

INT_VAR_DEFAULT = 0

The default behavior is CHOOSE_FIRST_UNBOUND.

INT_VAR_SIMPLE = 1

The simple selection is CHOOSE_FIRST_UNBOUND.

CHOOSE_FIRST_UNBOUND = 2

Select the first unbound variable. Variables are considered in the order of the vector of IntVars used to create the selector.

CHOOSE_RANDOM = 3

Randomly select one of the remaining unbound variables.

CHOOSE_MIN_SIZE_LOWEST_MIN = 4

Among unbound variables, select the variable with the smallest size, i.e., the smallest number of possible values. In case of a tie, the selected variables is the one with the lowest min value. In case of a tie, the first one is selected, first being defined by the order in the vector of IntVars used to create the selector.

CHOOSE_MIN_SIZE_HIGHEST_MIN = 5

Among unbound variables, select the variable with the smallest size, i.e., the smallest number of possible values. In case of a tie, the selected variable is the one with the highest min value. In case of a tie, the first one is selected, first being defined by the order in the vector of IntVars used to create the selector.

CHOOSE_MIN_SIZE_LOWEST_MAX = 6

Among unbound variables, select the variable with the smallest size, i.e., the smallest number of possible values. In case of a tie, the selected variables is the one with the lowest max value. In case of a tie, the first one is selected, first being defined by the order in the vector of IntVars used to create the selector.

CHOOSE_MIN_SIZE_HIGHEST_MAX = 7

Among unbound variables, select the variable with the smallest size, i.e., the smallest number of possible values. In case of a tie, the selected variable is the one with the highest max value. In case of a tie, the first one is selected, first being defined by the order in the vector of IntVars used to create the selector.

CHOOSE_LOWEST_MIN = 8

Among unbound variables, select the variable with the smallest minimal value. In case of a tie, the first one is selected, "first" defined by the order in the vector of IntVars used to create the selector.

CHOOSE_HIGHEST_MAX = 9

Among unbound variables, select the variable with the highest maximal value. In case of a tie, the first one is selected, first being defined by the order in the vector of IntVars used to create the selector.

CHOOSE_MIN_SIZE = 10

Among unbound variables, select the variable with the smallest size. In case of a tie, the first one is selected, first being defined by the order in the vector of IntVars used to create the selector.

CHOOSE_MAX_SIZE = 11

Among unbound variables, select the variable with the highest size. In case of a tie, the first one is selected, first being defined by the order in the vector of IntVars used to create the selector.

CHOOSE_MAX_REGRET_ON_MIN = 12

Among unbound variables, select the variable with the largest gap between the first and the second values of the domain.

CHOOSE_PATH = 13

Selects the next unbound variable on a path, the path being defined by the variables: var[i] corresponds to the index of the next of i.

INT_VALUE_DEFAULT = 0

The default behavior is ASSIGN_MIN_VALUE.

INT_VALUE_SIMPLE = 1

The simple selection is ASSIGN_MIN_VALUE.

ASSIGN_MIN_VALUE = 2

Selects the min value of the selected variable.

ASSIGN_MAX_VALUE = 3

Selects the max value of the selected variable.

ASSIGN_RANDOM_VALUE = 4

Selects randomly one of the possible values of the selected variable.

ASSIGN_CENTER_VALUE = 5

Selects the first possible value which is the closest to the center of the domain of the selected variable. The center is defined as (min + max) / 2.

SPLIT_LOWER_HALF = 6

Split the domain in two around the center, and choose the lower part first.

SPLIT_UPPER_HALF = 7

Split the domain in two around the center, and choose the lower part first.

INTERVAL_DEFAULT = 0

The default is INTERVAL_SET_TIMES_FORWARD.

INTERVAL_SIMPLE = 1

The simple is INTERVAL_SET_TIMES_FORWARD.

INTERVAL_SET_TIMES_FORWARD = 2

Selects the variable with the lowest starting time of all variables, and fixes its starting time to this lowest value.

INTERVAL_SET_TIMES_BACKWARD = 3

Selects the variable with the highest ending time of all variables, and fixes the ending time to this highest values.

TWOOPT = 0

Operator which reverses a sub-chain of a path. It is called TwoOpt because it breaks two arcs on the path; resulting paths are called two-optimal. Possible neighbors for the path 1 -> 2 -> 3 -> 4 -> 5 (where (1, 5) are first and last nodes of the path and can therefore not be moved): 1 -> [3 -> 2] -> 4 -> 5 1 -> [4 -> 3 -> 2] -> 5 1 -> 2 -> [4 -> 3] -> 5

OROPT = 1

Relocate: OROPT and RELOCATE. Operator which moves a sub-chain of a path to another position; the specified chain length is the fixed length of the chains being moved. When this length is 1, the operator simply moves a node to another position. Possible neighbors for the path 1 -> 2 -> 3 -> 4 -> 5, for a chain length of 2 (where (1, 5) are first and last nodes of the path and can therefore not be moved): 1 -> 4 -> [2 -> 3] -> 5 1 -> [3 -> 4] -> 2 -> 5

Using Relocate with chain lengths of 1, 2 and 3 together is equivalent to the OrOpt operator on a path. The OrOpt operator is a limited version of 3Opt (breaks 3 arcs on a path).

RELOCATE = 2

Relocate neighborhood with length of 1 (see OROPT comment).

EXCHANGE = 3

Operator which exchanges the positions of two nodes. Possible neighbors for the path 1 -> 2 -> 3 -> 4 -> 5 (where (1, 5) are first and last nodes of the path and can therefore not be moved): 1 -> [3] -> [2] -> 4 -> 5 1 -> [4] -> 3 -> [2] -> 5 1 -> 2 -> [4] -> [3] -> 5

CROSS = 4

Operator which cross exchanges the starting chains of 2 paths, including exchanging the whole paths. First and last nodes are not moved. Possible neighbors for the paths 1 -> 2 -> 3 -> 4 -> 5 and 6 -> 7 -> 8 (where (1, 5) and (6, 8) are first and last nodes of the paths and can therefore not be moved): 1 -> [7] -> 3 -> 4 -> 5 6 -> [2] -> 8 1 -> [7] -> 4 -> 5 6 -> [2 -> 3] -> 8 1 -> [7] -> 5 6 -> [2 -> 3 -> 4] -> 8

MAKEACTIVE = 5

Operator which inserts an inactive node into a path. Possible neighbors for the path 1 -> 2 -> 3 -> 4 with 5 inactive (where 1 and 4 are first and last nodes of the path) are: 1 -> [5] -> 2 -> 3 -> 4 1 -> 2 -> [5] -> 3 -> 4 1 -> 2 -> 3 -> [5] -> 4

MAKEINACTIVE = 6

Operator which makes path nodes inactive. Possible neighbors for the path 1 -> 2 -> 3 -> 4 (where 1 and 4 are first and last nodes of the path) are: 1 -> 3 -> 4 with 2 inactive 1 -> 2 -> 4 with 3 inactive

MAKECHAININACTIVE = 7

Operator which makes a "chain" of path nodes inactive. Possible neighbors for the path 1 -> 2 -> 3 -> 4 (where 1 and 4 are first and last nodes of the path) are: 1 -> 3 -> 4 with 2 inactive 1 -> 2 -> 4 with 3 inactive 1 -> 4 with 2 and 3 inactive

SWAPACTIVE = 8

Operator which replaces an active node by an inactive one. Possible neighbors for the path 1 -> 2 -> 3 -> 4 with 5 inactive (where 1 and 4 are first and last nodes of the path) are: 1 -> [5] -> 3 -> 4 with 2 inactive 1 -> 2 -> [5] -> 4 with 3 inactive

EXTENDEDSWAPACTIVE = 9

Operator which makes an inactive node active and an active one inactive. It is similar to SwapActiveOperator except that it tries to insert the inactive node in all possible positions instead of just the position of the node made inactive. Possible neighbors for the path 1 -> 2 -> 3 -> 4 with 5 inactive (where 1 and 4 are first and last nodes of the path) are: 1 -> [5] -> 3 -> 4 with 2 inactive 1 -> 3 -> [5] -> 4 with 2 inactive 1 -> [5] -> 2 -> 4 with 3 inactive 1 -> 2 -> [5] -> 4 with 3 inactive

PATHLNS = 10

Operator which relaxes two sub-chains of three consecutive arcs each. Each sub-chain is defined by a start node and the next three arcs. Those six arcs are relaxed to build a new neighbor. PATHLNS explores all possible pairs of starting nodes and so defines n^2 neighbors, n being the number of nodes. Note that the two sub-chains can be part of the same path; they even may overlap.

FULLPATHLNS = 11

Operator which relaxes one entire path and all inactive nodes, thus defining num_paths neighbors.

UNACTIVELNS = 12

Operator which relaxes all inactive nodes and one sub-chain of six consecutive arcs. That way the path can be improved by inserting inactive nodes or swapping arcs.

INCREMENT = 13

Operator which defines one neighbor per variable. Each neighbor tries to increment by one the value of the corresponding variable. When a new solution is found the neighborhood is rebuilt from scratch, i.e., tries to increment values in the variable order. Consider for instance variables x and y. x is incremented one by one to its max, and when it is not possible to increment x anymore, y is incremented once. If this is a solution, then next neighbor tries to increment x.

DECREMENT = 14

Operator which defines a neighborhood to decrement values. The behavior is the same as INCREMENT, except values are decremented instead of incremented.

SIMPLELNS = 15

Operator which defines one neighbor per variable. Each neighbor relaxes one variable. When a new solution is found the neighborhood is rebuilt from scratch. Consider for instance variables x and y. First x is relaxed and the solver is looking for the best possible solution (with only x relaxed). Then y is relaxed, and the solver is looking for a new solution. If a new solution is found, then the next variable to be relaxed is x.

GE = 0

Move is accepted when the current objective value >= objective.Min.

LE = 1

Move is accepted when the current objective value <= objective.Max.

EQ = 2

Move is accepted when the current objective value is in the interval objective.Min .. objective.Max.

DELAYED_PRIORITY = 0

DELAYED_PRIORITY is the lowest priority: Demons will be processed after VAR_PRIORITY and NORMAL_PRIORITY demons.

VAR_PRIORITY = 1

VAR_PRIORITY is between DELAYED_PRIORITY and NORMAL_PRIORITY.

NORMAL_PRIORITY = 2

NORMAL_PRIORITY is the highest priority: Demons will be processed first.

def Parameters(self):
445    def Parameters(self):
446        r""" Stored Parameters."""
447        return _pywrapcp.Solver_Parameters(self)

Stored Parameters.

@staticmethod
def DefaultSolverParameters():
449    @staticmethod
450    def DefaultSolverParameters():
451        r""" Create a ConstraintSolverParameters proto with all the default values."""
452        return _pywrapcp.Solver_DefaultSolverParameters()

Create a ConstraintSolverParameters proto with all the default values.

def AddConstraint(self, c):
454    def AddConstraint(self, c):
455        r"""
456        Adds the constraint 'c' to the model.
457
458        After calling this method, and until there is a backtrack that undoes the
459        addition, any assignment of variables to values must satisfy the given
460        constraint in order to be considered feasible. There are two fairly
461        different use cases:
462
463        - the most common use case is modeling: the given constraint is really
464        part of the problem that the user is trying to solve. In this use case,
465        AddConstraint is called outside of search (i.e., with state() ==
466        OUTSIDE_SEARCH). Most users should only use AddConstraint in this
467        way. In this case, the constraint will belong to the model forever: it
468        cannot not be removed by backtracking.
469
470        - a rarer use case is that 'c' is not a real constraint of the model. It
471        may be a constraint generated by a branching decision (a constraint whose
472        goal is to restrict the search space), a symmetry breaking constraint (a
473        constraint that does restrict the search space, but in a way that cannot
474        have an impact on the quality of the solutions in the subtree), or an
475        inferred constraint that, while having no semantic value to the model (it
476        does not restrict the set of solutions), is worth having because we
477        believe it may strengthen the propagation. In these cases, it happens
478        that the constraint is added during the search (i.e., with state() ==
479        IN_SEARCH or state() == IN_ROOT_NODE). When a constraint is
480        added during a search, it applies only to the subtree of the search tree
481        rooted at the current node, and will be automatically removed by
482        backtracking.
483
484        This method does not take ownership of the constraint. If the constraint
485        has been created by any factory method (Solver::MakeXXX), it will
486        automatically be deleted. However, power users who implement their own
487        constraints should do: solver.AddConstraint(solver.RevAlloc(new
488        MyConstraint(...));
489        """
490        return _pywrapcp.Solver_AddConstraint(self, c)

Adds the constraint 'c' to the model.

After calling this method, and until there is a backtrack that undoes the addition, any assignment of variables to values must satisfy the given constraint in order to be considered feasible. There are two fairly different use cases:

  • the most common use case is modeling: the given constraint is really part of the problem that the user is trying to solve. In this use case, AddConstraint is called outside of search (i.e., with state() == OUTSIDE_SEARCH). Most users should only use AddConstraint in this way. In this case, the constraint will belong to the model forever: it cannot not be removed by backtracking.

  • a rarer use case is that 'c' is not a real constraint of the model. It may be a constraint generated by a branching decision (a constraint whose goal is to restrict the search space), a symmetry breaking constraint (a constraint that does restrict the search space, but in a way that cannot have an impact on the quality of the solutions in the subtree), or an inferred constraint that, while having no semantic value to the model (it does not restrict the set of solutions), is worth having because we believe it may strengthen the propagation. In these cases, it happens that the constraint is added during the search (i.e., with state() == IN_SEARCH or state() == IN_ROOT_NODE). When a constraint is added during a search, it applies only to the subtree of the search tree rooted at the current node, and will be automatically removed by backtracking.

This method does not take ownership of the constraint. If the constraint has been created by any factory method (Solver::MakeXXX), it will automatically be deleted. However, power users who implement their own constraints should do: solver.AddConstraint(solver.RevAlloc(new MyConstraint(...));

def Solve(self, *args):
492    def Solve(self, *args):
493        return _pywrapcp.Solver_Solve(self, *args)
def NewSearch(self, *args):
495    def NewSearch(self, *args):
496        return _pywrapcp.Solver_NewSearch(self, *args)
def NextSolution(self):
498    def NextSolution(self):
499        return _pywrapcp.Solver_NextSolution(self)
def RestartSearch(self):
501    def RestartSearch(self):
502        return _pywrapcp.Solver_RestartSearch(self)
def EndSearch(self):
504    def EndSearch(self):
505        return _pywrapcp.Solver_EndSearch(self)
def SolveAndCommit(self, *args):
507    def SolveAndCommit(self, *args):
508        return _pywrapcp.Solver_SolveAndCommit(self, *args)
def CheckAssignment(self, solution):
510    def CheckAssignment(self, solution):
511        r""" Checks whether the given assignment satisfies all relevant constraints."""
512        return _pywrapcp.Solver_CheckAssignment(self, solution)

Checks whether the given assignment satisfies all relevant constraints.

def CheckConstraint(self, ct):
514    def CheckConstraint(self, ct):
515        r"""
516        Checks whether adding this constraint will lead to an immediate
517        failure. It will return false if the model is already inconsistent, or if
518        adding the constraint makes it inconsistent.
519        """
520        return _pywrapcp.Solver_CheckConstraint(self, ct)

Checks whether adding this constraint will lead to an immediate failure. It will return false if the model is already inconsistent, or if adding the constraint makes it inconsistent.

def Fail(self):
522    def Fail(self):
523        r""" Abandon the current branch in the search tree. A backtrack will follow."""
524        return _pywrapcp.Solver_Fail(self)

Abandon the current branch in the search tree. A backtrack will follow.

@staticmethod
def MemoryUsage():
526    @staticmethod
527    def MemoryUsage():
528        r""" Current memory usage in bytes"""
529        return _pywrapcp.Solver_MemoryUsage()

Current memory usage in bytes

def WallTime(self):
531    def WallTime(self):
532        r"""
533        DEPRECATED: Use Now() instead.
534        Time elapsed, in ms since the creation of the solver.
535        """
536        return _pywrapcp.Solver_WallTime(self)

DEPRECATED: Use Now() instead. Time elapsed, in ms since the creation of the solver.

def Branches(self):
538    def Branches(self):
539        r""" The number of branches explored since the creation of the solver."""
540        return _pywrapcp.Solver_Branches(self)

The number of branches explored since the creation of the solver.

def Solutions(self):
542    def Solutions(self):
543        r""" The number of solutions found since the start of the search."""
544        return _pywrapcp.Solver_Solutions(self)

The number of solutions found since the start of the search.

def Failures(self):
546    def Failures(self):
547        r""" The number of failures encountered since the creation of the solver."""
548        return _pywrapcp.Solver_Failures(self)

The number of failures encountered since the creation of the solver.

def AcceptedNeighbors(self):
550    def AcceptedNeighbors(self):
551        r""" The number of accepted neighbors."""
552        return _pywrapcp.Solver_AcceptedNeighbors(self)

The number of accepted neighbors.

def Stamp(self):
554    def Stamp(self):
555        r"""
556        The stamp indicates how many moves in the search tree we have performed.
557        It is useful to detect if we need to update same lazy structures.
558        """
559        return _pywrapcp.Solver_Stamp(self)

The stamp indicates how many moves in the search tree we have performed. It is useful to detect if we need to update same lazy structures.

def FailStamp(self):
561    def FailStamp(self):
562        r""" The fail_stamp() is incremented after each backtrack."""
563        return _pywrapcp.Solver_FailStamp(self)

The fail_stamp() is incremented after each backtrack.

def IntVar(self, *args):
565    def IntVar(self, *args):
566        r"""
567        *Overload 1:*
568        MakeIntVar will create the best range based int var for the bounds given.
569
570        |
571
572        *Overload 2:*
573        MakeIntVar will create a variable with the given sparse domain.
574
575        |
576
577        *Overload 3:*
578        MakeIntVar will create a variable with the given sparse domain.
579
580        |
581
582        *Overload 4:*
583        MakeIntVar will create the best range based int var for the bounds given.
584
585        |
586
587        *Overload 5:*
588        MakeIntVar will create a variable with the given sparse domain.
589
590        |
591
592        *Overload 6:*
593        MakeIntVar will create a variable with the given sparse domain.
594        """
595        return _pywrapcp.Solver_IntVar(self, *args)

Overload 1: MakeIntVar will create the best range based int var for the bounds given.

|

Overload 2: MakeIntVar will create a variable with the given sparse domain.

|

Overload 3: MakeIntVar will create a variable with the given sparse domain.

|

Overload 4: MakeIntVar will create the best range based int var for the bounds given.

|

Overload 5: MakeIntVar will create a variable with the given sparse domain.

|

Overload 6: MakeIntVar will create a variable with the given sparse domain.

def BoolVar(self, *args):
597    def BoolVar(self, *args):
598        r"""
599        *Overload 1:*
600        MakeBoolVar will create a variable with a {0, 1} domain.
601
602        |
603
604        *Overload 2:*
605        MakeBoolVar will create a variable with a {0, 1} domain.
606        """
607        return _pywrapcp.Solver_BoolVar(self, *args)

Overload 1: MakeBoolVar will create a variable with a {0, 1} domain.

|

Overload 2: MakeBoolVar will create a variable with a {0, 1} domain.

def IntConst(self, *args):
609    def IntConst(self, *args):
610        r"""
611        *Overload 1:*
612        IntConst will create a constant expression.
613
614        |
615
616        *Overload 2:*
617        IntConst will create a constant expression.
618        """
619        return _pywrapcp.Solver_IntConst(self, *args)

Overload 1: IntConst will create a constant expression.

|

Overload 2: IntConst will create a constant expression.

def Sum(self, vars):
621    def Sum(self, vars):
622        r""" sum of all vars."""
623        return _pywrapcp.Solver_Sum(self, vars)

sum of all vars.

def ScalProd(self, *args):
625    def ScalProd(self, *args):
626        r"""
627        *Overload 1:*
628        scalar product
629
630        |
631
632        *Overload 2:*
633        scalar product
634        """
635        return _pywrapcp.Solver_ScalProd(self, *args)

Overload 1: scalar product

|

Overload 2: scalar product

def MonotonicElement(self, values, increasing, index):
637    def MonotonicElement(self, values, increasing, index):
638        r"""
639        Function based element. The constraint takes ownership of the
640        callback.  The callback must be monotonic. It must be able to
641        cope with any possible value in the domain of 'index'
642        (potentially negative ones too). Furtermore, monotonicity is not
643        checked. Thus giving a non-monotonic function, or specifying an
644        incorrect increasing parameter will result in undefined behavior.
645        """
646        return _pywrapcp.Solver_MonotonicElement(self, values, increasing, index)

Function based element. The constraint takes ownership of the callback. The callback must be monotonic. It must be able to cope with any possible value in the domain of 'index' (potentially negative ones too). Furtermore, monotonicity is not checked. Thus giving a non-monotonic function, or specifying an incorrect increasing parameter will result in undefined behavior.

def Element(self, *args):
648    def Element(self, *args):
649        r"""
650        *Overload 1:*
651        values[index]
652
653        |
654
655        *Overload 2:*
656        values[index]
657
658        |
659
660        *Overload 3:*
661        Function-based element. The constraint takes ownership of the
662        callback. The callback must be able to cope with any possible
663        value in the domain of 'index' (potentially negative ones too).
664
665        |
666
667        *Overload 4:*
668        2D version of function-based element expression, values(expr1, expr2).
669
670        |
671
672        *Overload 5:*
673        vars[expr]
674        """
675        return _pywrapcp.Solver_Element(self, *args)

Overload 1: values[index]

|

Overload 2: values[index]

|

Overload 3: Function-based element. The constraint takes ownership of the callback. The callback must be able to cope with any possible value in the domain of 'index' (potentially negative ones too).

|

Overload 4: 2D version of function-based element expression, values(expr1, expr2).

|

Overload 5: vars[expr]

def IndexExpression(self, vars, value):
677    def IndexExpression(self, vars, value):
678        r"""
679        Returns the expression expr such that vars[expr] == value.
680        It assumes that vars are all different.
681        """
682        return _pywrapcp.Solver_IndexExpression(self, vars, value)

Returns the expression expr such that vars[expr] == value. It assumes that vars are all different.

def Min(self, *args):
684    def Min(self, *args):
685        r"""
686        *Overload 1:*
687        std::min(vars)
688
689        |
690
691        *Overload 2:*
692        std::min (left, right)
693
694        |
695
696        *Overload 3:*
697        std::min(expr, value)
698
699        |
700
701        *Overload 4:*
702        std::min(expr, value)
703        """
704        return _pywrapcp.Solver_Min(self, *args)

Overload 1: std::min(vars)

|

Overload 2: std::min (left, right)

|

Overload 3: std::min(expr, value)

|

Overload 4: std::min(expr, value)

def Max(self, *args):
706    def Max(self, *args):
707        r"""
708        *Overload 1:*
709        std::max(vars)
710
711        |
712
713        *Overload 2:*
714        std::max(left, right)
715
716        |
717
718        *Overload 3:*
719        std::max(expr, value)
720
721        |
722
723        *Overload 4:*
724        std::max(expr, value)
725        """
726        return _pywrapcp.Solver_Max(self, *args)

Overload 1: std::max(vars)

|

Overload 2: std::max(left, right)

|

Overload 3: std::max(expr, value)

|

Overload 4: std::max(expr, value)

def ConvexPiecewiseExpr(self, expr, early_cost, early_date, late_date, late_cost):
728    def ConvexPiecewiseExpr(self, expr, early_cost, early_date, late_date, late_cost):
729        r""" Convex piecewise function."""
730        return _pywrapcp.Solver_ConvexPiecewiseExpr(self, expr, early_cost, early_date, late_date, late_cost)

Convex piecewise function.

def SemiContinuousExpr(self, expr, fixed_charge, step):
732    def SemiContinuousExpr(self, expr, fixed_charge, step):
733        r"""
734        Semi continuous Expression (x <= 0 -> f(x) = 0; x > 0 -> f(x) = ax + b)
735        a >= 0 and b >= 0
736        """
737        return _pywrapcp.Solver_SemiContinuousExpr(self, expr, fixed_charge, step)

Semi continuous Expression (x <= 0 -> f(x) = 0; x > 0 -> f(x) = ax + b) a >= 0 and b >= 0

def ConditionalExpression(self, condition, expr, unperformed_value):
739    def ConditionalExpression(self, condition, expr, unperformed_value):
740        r""" Conditional Expr condition ? expr : unperformed_value"""
741        return _pywrapcp.Solver_ConditionalExpression(self, condition, expr, unperformed_value)

Conditional Expr condition ? expr : unperformed_value

def TrueConstraint(self):
743    def TrueConstraint(self):
744        r""" This constraint always succeeds."""
745        return _pywrapcp.Solver_TrueConstraint(self)

This constraint always succeeds.

def FalseConstraint(self, *args):
747    def FalseConstraint(self, *args):
748        return _pywrapcp.Solver_FalseConstraint(self, *args)
def IsEqualCstCt(self, var, value, boolvar):
750    def IsEqualCstCt(self, var, value, boolvar):
751        r""" boolvar == (var == value)"""
752        return _pywrapcp.Solver_IsEqualCstCt(self, var, value, boolvar)

boolvar == (var == value)

def IsEqualCstVar(self, var, value):
754    def IsEqualCstVar(self, var, value):
755        r""" status var of (var == value)"""
756        return _pywrapcp.Solver_IsEqualCstVar(self, var, value)

status var of (var == value)

def IsEqualCt(self, v1, v2, b):
758    def IsEqualCt(self, v1, v2, b):
759        r""" b == (v1 == v2)"""
760        return _pywrapcp.Solver_IsEqualCt(self, v1, v2, b)

b == (v1 == v2)

def IsEqualVar(self, v1, v2):
762    def IsEqualVar(self, v1, v2):
763        r""" status var of (v1 == v2)"""
764        return _pywrapcp.Solver_IsEqualVar(self, v1, v2)

status var of (v1 == v2)

def IsDifferentCstCt(self, var, value, boolvar):
766    def IsDifferentCstCt(self, var, value, boolvar):
767        r""" boolvar == (var != value)"""
768        return _pywrapcp.Solver_IsDifferentCstCt(self, var, value, boolvar)

boolvar == (var != value)

def IsDifferentCstVar(self, var, value):
770    def IsDifferentCstVar(self, var, value):
771        r""" status var of (var != value)"""
772        return _pywrapcp.Solver_IsDifferentCstVar(self, var, value)

status var of (var != value)

def IsDifferentVar(self, v1, v2):
774    def IsDifferentVar(self, v1, v2):
775        r""" status var of (v1 != v2)"""
776        return _pywrapcp.Solver_IsDifferentVar(self, v1, v2)

status var of (v1 != v2)

def IsDifferentCt(self, v1, v2, b):
778    def IsDifferentCt(self, v1, v2, b):
779        r""" b == (v1 != v2)"""
780        return _pywrapcp.Solver_IsDifferentCt(self, v1, v2, b)

b == (v1 != v2)

def IsLessOrEqualCstCt(self, var, value, boolvar):
782    def IsLessOrEqualCstCt(self, var, value, boolvar):
783        r""" boolvar == (var <= value)"""
784        return _pywrapcp.Solver_IsLessOrEqualCstCt(self, var, value, boolvar)

boolvar == (var <= value)

def IsLessOrEqualCstVar(self, var, value):
786    def IsLessOrEqualCstVar(self, var, value):
787        r""" status var of (var <= value)"""
788        return _pywrapcp.Solver_IsLessOrEqualCstVar(self, var, value)

status var of (var <= value)

def IsLessOrEqualVar(self, left, right):
790    def IsLessOrEqualVar(self, left, right):
791        r""" status var of (left <= right)"""
792        return _pywrapcp.Solver_IsLessOrEqualVar(self, left, right)

status var of (left <= right)

def IsLessOrEqualCt(self, left, right, b):
794    def IsLessOrEqualCt(self, left, right, b):
795        r""" b == (left <= right)"""
796        return _pywrapcp.Solver_IsLessOrEqualCt(self, left, right, b)

b == (left <= right)

def IsGreaterOrEqualCstCt(self, var, value, boolvar):
798    def IsGreaterOrEqualCstCt(self, var, value, boolvar):
799        r""" boolvar == (var >= value)"""
800        return _pywrapcp.Solver_IsGreaterOrEqualCstCt(self, var, value, boolvar)

boolvar == (var >= value)

def IsGreaterOrEqualCstVar(self, var, value):
802    def IsGreaterOrEqualCstVar(self, var, value):
803        r""" status var of (var >= value)"""
804        return _pywrapcp.Solver_IsGreaterOrEqualCstVar(self, var, value)

status var of (var >= value)

def IsGreaterOrEqualVar(self, left, right):
806    def IsGreaterOrEqualVar(self, left, right):
807        r""" status var of (left >= right)"""
808        return _pywrapcp.Solver_IsGreaterOrEqualVar(self, left, right)

status var of (left >= right)

def IsGreaterOrEqualCt(self, left, right, b):
810    def IsGreaterOrEqualCt(self, left, right, b):
811        r""" b == (left >= right)"""
812        return _pywrapcp.Solver_IsGreaterOrEqualCt(self, left, right, b)

b == (left >= right)

def IsGreaterCstCt(self, v, c, b):
814    def IsGreaterCstCt(self, v, c, b):
815        r""" b == (v > c)"""
816        return _pywrapcp.Solver_IsGreaterCstCt(self, v, c, b)

b == (v > c)

def IsGreaterCstVar(self, var, value):
818    def IsGreaterCstVar(self, var, value):
819        r""" status var of (var > value)"""
820        return _pywrapcp.Solver_IsGreaterCstVar(self, var, value)

status var of (var > value)

def IsGreaterVar(self, left, right):
822    def IsGreaterVar(self, left, right):
823        r""" status var of (left > right)"""
824        return _pywrapcp.Solver_IsGreaterVar(self, left, right)

status var of (left > right)

def IsGreaterCt(self, left, right, b):
826    def IsGreaterCt(self, left, right, b):
827        r""" b == (left > right)"""
828        return _pywrapcp.Solver_IsGreaterCt(self, left, right, b)

b == (left > right)

def IsLessCstCt(self, v, c, b):
830    def IsLessCstCt(self, v, c, b):
831        r""" b == (v < c)"""
832        return _pywrapcp.Solver_IsLessCstCt(self, v, c, b)

b == (v < c)

def IsLessCstVar(self, var, value):
834    def IsLessCstVar(self, var, value):
835        r""" status var of (var < value)"""
836        return _pywrapcp.Solver_IsLessCstVar(self, var, value)

status var of (var < value)

def IsLessVar(self, left, right):
838    def IsLessVar(self, left, right):
839        r""" status var of (left < right)"""
840        return _pywrapcp.Solver_IsLessVar(self, left, right)

status var of (left < right)

def IsLessCt(self, left, right, b):
842    def IsLessCt(self, left, right, b):
843        r""" b == (left < right)"""
844        return _pywrapcp.Solver_IsLessCt(self, left, right, b)

b == (left < right)

def SumLessOrEqual(self, vars, cst):
846    def SumLessOrEqual(self, vars, cst):
847        r""" Variation on arrays."""
848        return _pywrapcp.Solver_SumLessOrEqual(self, vars, cst)

Variation on arrays.

def SumGreaterOrEqual(self, vars, cst):
850    def SumGreaterOrEqual(self, vars, cst):
851        return _pywrapcp.Solver_SumGreaterOrEqual(self, vars, cst)
def SumEquality(self, *args):
853    def SumEquality(self, *args):
854        return _pywrapcp.Solver_SumEquality(self, *args)
def ScalProdEquality(self, *args):
856    def ScalProdEquality(self, *args):
857        return _pywrapcp.Solver_ScalProdEquality(self, *args)
def ScalProdGreaterOrEqual(self, *args):
859    def ScalProdGreaterOrEqual(self, *args):
860        return _pywrapcp.Solver_ScalProdGreaterOrEqual(self, *args)
def ScalProdLessOrEqual(self, *args):
862    def ScalProdLessOrEqual(self, *args):
863        return _pywrapcp.Solver_ScalProdLessOrEqual(self, *args)
def MinEquality(self, vars, min_var):
865    def MinEquality(self, vars, min_var):
866        return _pywrapcp.Solver_MinEquality(self, vars, min_var)
def MaxEquality(self, vars, max_var):
868    def MaxEquality(self, vars, max_var):
869        return _pywrapcp.Solver_MaxEquality(self, vars, max_var)
def ElementEquality(self, *args):
871    def ElementEquality(self, *args):
872        return _pywrapcp.Solver_ElementEquality(self, *args)
def AbsEquality(self, var, abs_var):
874    def AbsEquality(self, var, abs_var):
875        r""" Creates the constraint abs(var) == abs_var."""
876        return _pywrapcp.Solver_AbsEquality(self, var, abs_var)

Creates the constraint abs(var) == abs_var.

def IndexOfConstraint(self, vars, index, target):
878    def IndexOfConstraint(self, vars, index, target):
879        r"""
880        This constraint is a special case of the element constraint with
881        an array of integer variables, where the variables are all
882        different and the index variable is constrained such that
883        vars[index] == target.
884        """
885        return _pywrapcp.Solver_IndexOfConstraint(self, vars, index, target)

This constraint is a special case of the element constraint with an array of integer variables, where the variables are all different and the index variable is constrained such that vars[index] == target.

def ConstraintInitialPropagateCallback(self, ct):
887    def ConstraintInitialPropagateCallback(self, ct):
888        r"""
889        This method is a specialized case of the MakeConstraintDemon
890        method to call the InitiatePropagate of the constraint 'ct'.
891        """
892        return _pywrapcp.Solver_ConstraintInitialPropagateCallback(self, ct)

This method is a specialized case of the MakeConstraintDemon method to call the InitiatePropagate of the constraint 'ct'.

def DelayedConstraintInitialPropagateCallback(self, ct):
894    def DelayedConstraintInitialPropagateCallback(self, ct):
895        r"""
896        This method is a specialized case of the MakeConstraintDemon
897        method to call the InitiatePropagate of the constraint 'ct' with
898        low priority.
899        """
900        return _pywrapcp.Solver_DelayedConstraintInitialPropagateCallback(self, ct)

This method is a specialized case of the MakeConstraintDemon method to call the InitiatePropagate of the constraint 'ct' with low priority.

def ClosureDemon(self, closure):
902    def ClosureDemon(self, closure):
903        r""" Creates a demon from a closure."""
904        return _pywrapcp.Solver_ClosureDemon(self, closure)

Creates a demon from a closure.

def BetweenCt(self, expr, l, u):
906    def BetweenCt(self, expr, l, u):
907        r""" (l <= expr <= u)"""
908        return _pywrapcp.Solver_BetweenCt(self, expr, l, u)

(l <= expr <= u)

def IsBetweenCt(self, expr, l, u, b):
910    def IsBetweenCt(self, expr, l, u, b):
911        r""" b == (l <= expr <= u)"""
912        return _pywrapcp.Solver_IsBetweenCt(self, expr, l, u, b)

b == (l <= expr <= u)

def IsBetweenVar(self, v, l, u):
914    def IsBetweenVar(self, v, l, u):
915        return _pywrapcp.Solver_IsBetweenVar(self, v, l, u)
def MemberCt(self, *args):
917    def MemberCt(self, *args):
918        return _pywrapcp.Solver_MemberCt(self, *args)
def NotMemberCt(self, *args):
920    def NotMemberCt(self, *args):
921        r"""
922        *Overload 1:*
923        expr not in set.
924
925        |
926
927        *Overload 2:*
928        expr should not be in the list of forbidden intervals [start[i]..end[i]].
929
930        |
931
932        *Overload 3:*
933        expr should not be in the list of forbidden intervals [start[i]..end[i]].
934        """
935        return _pywrapcp.Solver_NotMemberCt(self, *args)

Overload 1: expr not in set.

|

Overload 2: expr should not be in the list of forbidden intervals [start[i]..end[i]].

|

Overload 3: expr should not be in the list of forbidden intervals [start[i]..end[i]].

def IsMemberCt(self, *args):
937    def IsMemberCt(self, *args):
938        return _pywrapcp.Solver_IsMemberCt(self, *args)
def IsMemberVar(self, *args):
940    def IsMemberVar(self, *args):
941        return _pywrapcp.Solver_IsMemberVar(self, *args)
def Count(self, *args):
943    def Count(self, *args):
944        r"""
945        *Overload 1:*
946        |{i | vars[i] == value}| == max_count
947
948        |
949
950        *Overload 2:*
951        |{i | vars[i] == value}| == max_count
952        """
953        return _pywrapcp.Solver_Count(self, *args)

Overload 1: |{i | vars[i] == value}| == max_count

|

Overload 2: |{i | vars[i] == value}| == max_count

def Distribute(self, *args):
 955    def Distribute(self, *args):
 956        r"""
 957        *Overload 1:*
 958        Aggregated version of count:  |{i | v[i] == values[j]}| == cards[j]
 959
 960        |
 961
 962        *Overload 2:*
 963        Aggregated version of count:  |{i | v[i] == values[j]}| == cards[j]
 964
 965        |
 966
 967        *Overload 3:*
 968        Aggregated version of count:  |{i | v[i] == j}| == cards[j]
 969
 970        |
 971
 972        *Overload 4:*
 973        Aggregated version of count with bounded cardinalities:
 974        forall j in 0 .. card_size - 1: card_min <= |{i | v[i] == j}| <= card_max
 975
 976        |
 977
 978        *Overload 5:*
 979        Aggregated version of count with bounded cardinalities:
 980        forall j in 0 .. card_size - 1:
 981           card_min[j] <= |{i | v[i] == j}| <= card_max[j]
 982
 983        |
 984
 985        *Overload 6:*
 986        Aggregated version of count with bounded cardinalities:
 987        forall j in 0 .. card_size - 1:
 988           card_min[j] <= |{i | v[i] == j}| <= card_max[j]
 989
 990        |
 991
 992        *Overload 7:*
 993        Aggregated version of count with bounded cardinalities:
 994        forall j in 0 .. card_size - 1:
 995           card_min[j] <= |{i | v[i] == values[j]}| <= card_max[j]
 996
 997        |
 998
 999        *Overload 8:*
1000        Aggregated version of count with bounded cardinalities:
1001        forall j in 0 .. card_size - 1:
1002           card_min[j] <= |{i | v[i] == values[j]}| <= card_max[j]
1003        """
1004        return _pywrapcp.Solver_Distribute(self, *args)

Overload 1: Aggregated version of count: |{i | v[i] == values[j]}| == cards[j]

|

Overload 2: Aggregated version of count: |{i | v[i] == values[j]}| == cards[j]

|

Overload 3: Aggregated version of count: |{i | v[i] == j}| == cards[j]

|

Overload 4: Aggregated version of count with bounded cardinalities: forall j in 0 .. card_size - 1: card_min <= |{i | v[i] == j}| <= card_max

|

Overload 5: Aggregated version of count with bounded cardinalities: forall j in 0 .. card_size - 1: card_min[j] <= |{i | v[i] == j}| <= card_max[j]

|

Overload 6: Aggregated version of count with bounded cardinalities: forall j in 0 .. card_size - 1: card_min[j] <= |{i | v[i] == j}| <= card_max[j]

|

Overload 7: Aggregated version of count with bounded cardinalities: forall j in 0 .. card_size - 1: card_min[j] <= |{i | v[i] == values[j]}| <= card_max[j]

|

Overload 8: Aggregated version of count with bounded cardinalities: forall j in 0 .. card_size - 1: card_min[j] <= |{i | v[i] == values[j]}| <= card_max[j]

def Deviation(self, vars, deviation_var, total_sum):
1006    def Deviation(self, vars, deviation_var, total_sum):
1007        r"""
1008        Deviation constraint:
1009        sum_i |n * vars[i] - total_sum| <= deviation_var and
1010        sum_i vars[i] == total_sum
1011        n = #vars
1012        """
1013        return _pywrapcp.Solver_Deviation(self, vars, deviation_var, total_sum)

Deviation constraint: sum_i |n * vars[i] - total_sum| <= deviation_var and sum_i vars[i] == total_sum n = #vars

def AllDifferent(self, *args):
1015    def AllDifferent(self, *args):
1016        r"""
1017        *Overload 1:*
1018        All variables are pairwise different. This corresponds to the
1019        stronger version of the propagation algorithm.
1020
1021        |
1022
1023        *Overload 2:*
1024        All variables are pairwise different.  If 'stronger_propagation'
1025        is true, stronger, and potentially slower propagation will
1026        occur. This API will be deprecated in the future.
1027        """
1028        return _pywrapcp.Solver_AllDifferent(self, *args)

Overload 1: All variables are pairwise different. This corresponds to the stronger version of the propagation algorithm.

|

Overload 2: All variables are pairwise different. If 'stronger_propagation' is true, stronger, and potentially slower propagation will occur. This API will be deprecated in the future.

def AllDifferentExcept(self, vars, escape_value):
1030    def AllDifferentExcept(self, vars, escape_value):
1031        r"""
1032        All variables are pairwise different, unless they are assigned to
1033        the escape value.
1034        """
1035        return _pywrapcp.Solver_AllDifferentExcept(self, vars, escape_value)

All variables are pairwise different, unless they are assigned to the escape value.

def SortingConstraint(self, vars, sorted):
1037    def SortingConstraint(self, vars, sorted):
1038        r"""
1039        Creates a constraint binding the arrays of variables "vars" and
1040        "sorted_vars": sorted_vars[0] must be equal to the minimum of all
1041        variables in vars, and so on: the value of sorted_vars[i] must be
1042        equal to the i-th value of variables invars.
1043
1044        This constraint propagates in both directions: from "vars" to
1045        "sorted_vars" and vice-versa.
1046
1047        Behind the scenes, this constraint maintains that:
1048          - sorted is always increasing.
1049          - whatever the values of vars, there exists a permutation that
1050            injects its values into the sorted variables.
1051
1052        For more info, please have a look at:
1053          https://mpi-inf.mpg.de/~mehlhorn/ftp/Mehlhorn-Thiel.pdf
1054        """
1055        return _pywrapcp.Solver_SortingConstraint(self, vars, sorted)

Creates a constraint binding the arrays of variables "vars" and "sorted_vars": sorted_vars[0] must be equal to the minimum of all variables in vars, and so on: the value of sorted_vars[i] must be equal to the i-th value of variables invars.

This constraint propagates in both directions: from "vars" to "sorted_vars" and vice-versa.

Behind the scenes, this constraint maintains that:

  • sorted is always increasing.
  • whatever the values of vars, there exists a permutation that injects its values into the sorted variables.

For more info, please have a look at: https://mpi-inf.mpg.de/~mehlhorn/ftp/Mehlhorn-Thiel.pdf

def LexicalLess(self, left, right):
1057    def LexicalLess(self, left, right):
1058        r"""
1059        Creates a constraint that enforces that left is lexicographically less
1060        than right.
1061        """
1062        return _pywrapcp.Solver_LexicalLess(self, left, right)

Creates a constraint that enforces that left is lexicographically less than right.

def LexicalLessOrEqual(self, left, right):
1064    def LexicalLessOrEqual(self, left, right):
1065        r"""
1066        Creates a constraint that enforces that left is lexicographically less
1067        than or equal to right.
1068        """
1069        return _pywrapcp.Solver_LexicalLessOrEqual(self, left, right)

Creates a constraint that enforces that left is lexicographically less than or equal to right.

def InversePermutationConstraint(self, left, right):
1071    def InversePermutationConstraint(self, left, right):
1072        r"""
1073        Creates a constraint that enforces that 'left' and 'right' both
1074        represent permutations of [0..left.size()-1], and that 'right' is
1075        the inverse permutation of 'left', i.e. for all i in
1076        [0..left.size()-1], right[left[i]] = i.
1077        """
1078        return _pywrapcp.Solver_InversePermutationConstraint(self, left, right)

Creates a constraint that enforces that 'left' and 'right' both represent permutations of [0..left.size()-1], and that 'right' is the inverse permutation of 'left', i.e. for all i in [0..left.size()-1], right[left[i]] = i.

def NullIntersect(self, first_vars, second_vars):
1080    def NullIntersect(self, first_vars, second_vars):
1081        r"""
1082        Creates a constraint that states that all variables in the first
1083        vector are different from all variables in the second
1084        group. Thus the set of values in the first vector does not
1085        intersect with the set of values in the second vector.
1086        """
1087        return _pywrapcp.Solver_NullIntersect(self, first_vars, second_vars)

Creates a constraint that states that all variables in the first vector are different from all variables in the second group. Thus the set of values in the first vector does not intersect with the set of values in the second vector.

def NullIntersectExcept(self, first_vars, second_vars, escape_value):
1089    def NullIntersectExcept(self, first_vars, second_vars, escape_value):
1090        r"""
1091        Creates a constraint that states that all variables in the first
1092        vector are different from all variables from the second group,
1093        unless they are assigned to the escape value. Thus the set of
1094        values in the first vector minus the escape value does not
1095        intersect with the set of values in the second vector.
1096        """
1097        return _pywrapcp.Solver_NullIntersectExcept(self, first_vars, second_vars, escape_value)

Creates a constraint that states that all variables in the first vector are different from all variables from the second group, unless they are assigned to the escape value. Thus the set of values in the first vector minus the escape value does not intersect with the set of values in the second vector.

def Circuit(self, nexts):
1099    def Circuit(self, nexts):
1100        r""" Force the "nexts" variable to create a complete Hamiltonian path."""
1101        return _pywrapcp.Solver_Circuit(self, nexts)

Force the "nexts" variable to create a complete Hamiltonian path.

def SubCircuit(self, nexts):
1103    def SubCircuit(self, nexts):
1104        r"""
1105        Force the "nexts" variable to create a complete Hamiltonian path
1106        for those that do not loop upon themselves.
1107        """
1108        return _pywrapcp.Solver_SubCircuit(self, nexts)

Force the "nexts" variable to create a complete Hamiltonian path for those that do not loop upon themselves.

def DelayedPathCumul(self, nexts, active, cumuls, transits):
1110    def DelayedPathCumul(self, nexts, active, cumuls, transits):
1111        r"""
1112        Delayed version of the same constraint: propagation on the nexts variables
1113        is delayed until all constraints have propagated.
1114        """
1115        return _pywrapcp.Solver_DelayedPathCumul(self, nexts, active, cumuls, transits)

Delayed version of the same constraint: propagation on the nexts variables is delayed until all constraints have propagated.

def PathCumul(self, *args):
1117    def PathCumul(self, *args):
1118        r"""
1119        *Overload 1:*
1120        Creates a constraint which accumulates values along a path such that:
1121        cumuls[next[i]] = cumuls[i] + transits[i].
1122        Active variables indicate if the corresponding next variable is active;
1123        this could be useful to model unperformed nodes in a routing problem.
1124
1125        |
1126
1127        *Overload 2:*
1128        Creates a constraint which accumulates values along a path such that:
1129        cumuls[next[i]] = cumuls[i] + transit_evaluator(i, next[i]).
1130        Active variables indicate if the corresponding next variable is active;
1131        this could be useful to model unperformed nodes in a routing problem.
1132        Ownership of transit_evaluator is taken and it must be a repeatable
1133        callback.
1134
1135        |
1136
1137        *Overload 3:*
1138        Creates a constraint which accumulates values along a path such that:
1139        cumuls[next[i]] = cumuls[i] + transit_evaluator(i, next[i]) + slacks[i].
1140        Active variables indicate if the corresponding next variable is active;
1141        this could be useful to model unperformed nodes in a routing problem.
1142        Ownership of transit_evaluator is taken and it must be a repeatable
1143        callback.
1144        """
1145        return _pywrapcp.Solver_PathCumul(self, *args)

Overload 1: Creates a constraint which accumulates values along a path such that: cumuls[next[i]] = cumuls[i] + transits[i]. Active variables indicate if the corresponding next variable is active; this could be useful to model unperformed nodes in a routing problem.

|

Overload 2: Creates a constraint which accumulates values along a path such that: cumuls[next[i]] = cumuls[i] + transit_evaluator(i, next[i]). Active variables indicate if the corresponding next variable is active; this could be useful to model unperformed nodes in a routing problem. Ownership of transit_evaluator is taken and it must be a repeatable callback.

|

Overload 3: Creates a constraint which accumulates values along a path such that: cumuls[next[i]] = cumuls[i] + transit_evaluator(i, next[i]) + slacks[i]. Active variables indicate if the corresponding next variable is active; this could be useful to model unperformed nodes in a routing problem. Ownership of transit_evaluator is taken and it must be a repeatable callback.

def AllowedAssignments(self, *args):
1147    def AllowedAssignments(self, *args):
1148        r"""
1149        *Overload 1:*
1150        This method creates a constraint where the graph of the relation
1151        between the variables is given in extension. There are 'arity'
1152        variables involved in the relation and the graph is given by a
1153        integer tuple set.
1154
1155        |
1156
1157        *Overload 2:*
1158        Compatibility layer for Python API.
1159        """
1160        return _pywrapcp.Solver_AllowedAssignments(self, *args)

Overload 1: This method creates a constraint where the graph of the relation between the variables is given in extension. There are 'arity' variables involved in the relation and the graph is given by a integer tuple set.

|

Overload 2: Compatibility layer for Python API.

def TransitionConstraint(self, *args):
1162    def TransitionConstraint(self, *args):
1163        return _pywrapcp.Solver_TransitionConstraint(self, *args)
def NonOverlappingBoxesConstraint(self, *args):
1165    def NonOverlappingBoxesConstraint(self, *args):
1166        return _pywrapcp.Solver_NonOverlappingBoxesConstraint(self, *args)
def Pack(self, vars, number_of_bins):
1168    def Pack(self, vars, number_of_bins):
1169        r"""
1170        This constraint packs all variables onto 'number_of_bins'
1171        variables.  For any given variable, a value of 'number_of_bins'
1172        indicates that the variable is not assigned to any bin.
1173        Dimensions, i.e., cumulative constraints on this packing, can be
1174        added directly from the pack class.
1175        """
1176        return _pywrapcp.Solver_Pack(self, vars, number_of_bins)

This constraint packs all variables onto 'number_of_bins' variables. For any given variable, a value of 'number_of_bins' indicates that the variable is not assigned to any bin. Dimensions, i.e., cumulative constraints on this packing, can be added directly from the pack class.

def FixedDurationIntervalVar(self, *args):
1178    def FixedDurationIntervalVar(self, *args):
1179        r"""
1180        *Overload 1:*
1181        Creates an interval var with a fixed duration. The duration must
1182        be greater than 0. If optional is true, then the interval can be
1183        performed or unperformed. If optional is false, then the interval
1184        is always performed.
1185
1186        |
1187
1188        *Overload 2:*
1189        Creates a performed interval var with a fixed duration. The duration must
1190        be greater than 0.
1191
1192        |
1193
1194        *Overload 3:*
1195        Creates an interval var with a fixed duration, and performed_variable.
1196        The duration must be greater than 0.
1197        """
1198        return _pywrapcp.Solver_FixedDurationIntervalVar(self, *args)

Overload 1: Creates an interval var with a fixed duration. The duration must be greater than 0. If optional is true, then the interval can be performed or unperformed. If optional is false, then the interval is always performed.

|

Overload 2: Creates a performed interval var with a fixed duration. The duration must be greater than 0.

|

Overload 3: Creates an interval var with a fixed duration, and performed_variable. The duration must be greater than 0.

def FixedInterval(self, start, duration, name):
1200    def FixedInterval(self, start, duration, name):
1201        r""" Creates a fixed and performed interval."""
1202        return _pywrapcp.Solver_FixedInterval(self, start, duration, name)

Creates a fixed and performed interval.

def IntervalVar( self, start_min, start_max, duration_min, duration_max, end_min, end_max, optional, name):
1204    def IntervalVar(self, start_min, start_max, duration_min, duration_max, end_min, end_max, optional, name):
1205        r"""
1206        Creates an interval var by specifying the bounds on start,
1207        duration, and end.
1208        """
1209        return _pywrapcp.Solver_IntervalVar(self, start_min, start_max, duration_min, duration_max, end_min, end_max, optional, name)

Creates an interval var by specifying the bounds on start, duration, and end.

def MirrorInterval(self, interval_var):
1211    def MirrorInterval(self, interval_var):
1212        r"""
1213        Creates an interval var that is the mirror image of the given one, that
1214        is, the interval var obtained by reversing the axis.
1215        """
1216        return _pywrapcp.Solver_MirrorInterval(self, interval_var)

Creates an interval var that is the mirror image of the given one, that is, the interval var obtained by reversing the axis.

def FixedDurationStartSyncedOnStartIntervalVar(self, interval_var, duration, offset):
1218    def FixedDurationStartSyncedOnStartIntervalVar(self, interval_var, duration, offset):
1219        r"""
1220        Creates an interval var with a fixed duration whose start is
1221        synchronized with the start of another interval, with a given
1222        offset. The performed status is also in sync with the performed
1223        status of the given interval variable.
1224        """
1225        return _pywrapcp.Solver_FixedDurationStartSyncedOnStartIntervalVar(self, interval_var, duration, offset)

Creates an interval var with a fixed duration whose start is synchronized with the start of another interval, with a given offset. The performed status is also in sync with the performed status of the given interval variable.

def FixedDurationStartSyncedOnEndIntervalVar(self, interval_var, duration, offset):
1227    def FixedDurationStartSyncedOnEndIntervalVar(self, interval_var, duration, offset):
1228        r"""
1229        Creates an interval var with a fixed duration whose start is
1230        synchronized with the end of another interval, with a given
1231        offset. The performed status is also in sync with the performed
1232        status of the given interval variable.
1233        """
1234        return _pywrapcp.Solver_FixedDurationStartSyncedOnEndIntervalVar(self, interval_var, duration, offset)

Creates an interval var with a fixed duration whose start is synchronized with the end of another interval, with a given offset. The performed status is also in sync with the performed status of the given interval variable.

def FixedDurationEndSyncedOnStartIntervalVar(self, interval_var, duration, offset):
1236    def FixedDurationEndSyncedOnStartIntervalVar(self, interval_var, duration, offset):
1237        r"""
1238        Creates an interval var with a fixed duration whose end is
1239        synchronized with the start of another interval, with a given
1240        offset. The performed status is also in sync with the performed
1241        status of the given interval variable.
1242        """
1243        return _pywrapcp.Solver_FixedDurationEndSyncedOnStartIntervalVar(self, interval_var, duration, offset)

Creates an interval var with a fixed duration whose end is synchronized with the start of another interval, with a given offset. The performed status is also in sync with the performed status of the given interval variable.

def FixedDurationEndSyncedOnEndIntervalVar(self, interval_var, duration, offset):
1245    def FixedDurationEndSyncedOnEndIntervalVar(self, interval_var, duration, offset):
1246        r"""
1247        Creates an interval var with a fixed duration whose end is
1248        synchronized with the end of another interval, with a given
1249        offset. The performed status is also in sync with the performed
1250        status of the given interval variable.
1251        """
1252        return _pywrapcp.Solver_FixedDurationEndSyncedOnEndIntervalVar(self, interval_var, duration, offset)

Creates an interval var with a fixed duration whose end is synchronized with the end of another interval, with a given offset. The performed status is also in sync with the performed status of the given interval variable.

def IntervalRelaxedMin(self, interval_var):
1254    def IntervalRelaxedMin(self, interval_var):
1255        r"""
1256         Creates and returns an interval variable that wraps around the given one,
1257         relaxing the min start and end. Relaxing means making unbounded when
1258         optional. If the variable is non-optional, this method returns
1259         interval_var.
1260
1261         More precisely, such an interval variable behaves as follows:
1262        When the underlying must be performed, the returned interval variable
1263             behaves exactly as the underlying;
1264        When the underlying may or may not be performed, the returned interval
1265             variable behaves like the underlying, except that it is unbounded on
1266             the min side;
1267        When the underlying cannot be performed, the returned interval variable
1268             is of duration 0 and must be performed in an interval unbounded on
1269             both sides.
1270
1271         This is very useful to implement propagators that may only modify
1272         the start max or end max.
1273        """
1274        return _pywrapcp.Solver_IntervalRelaxedMin(self, interval_var)

Creates and returns an interval variable that wraps around the given one, relaxing the min start and end. Relaxing means making unbounded when optional. If the variable is non-optional, this method returns interval_var.

More precisely, such an interval variable behaves as follows: When the underlying must be performed, the returned interval variable behaves exactly as the underlying; When the underlying may or may not be performed, the returned interval variable behaves like the underlying, except that it is unbounded on the min side; When the underlying cannot be performed, the returned interval variable is of duration 0 and must be performed in an interval unbounded on both sides.

This is very useful to implement propagators that may only modify the start max or end max.

def IntervalRelaxedMax(self, interval_var):
1276    def IntervalRelaxedMax(self, interval_var):
1277        r"""
1278         Creates and returns an interval variable that wraps around the given one,
1279         relaxing the max start and end. Relaxing means making unbounded when
1280         optional. If the variable is non optional, this method returns
1281         interval_var.
1282
1283         More precisely, such an interval variable behaves as follows:
1284        When the underlying must be performed, the returned interval variable
1285             behaves exactly as the underlying;
1286        When the underlying may or may not be performed, the returned interval
1287             variable behaves like the underlying, except that it is unbounded on
1288             the max side;
1289        When the underlying cannot be performed, the returned interval variable
1290             is of duration 0 and must be performed in an interval unbounded on
1291             both sides.
1292
1293         This is very useful for implementing propagators that may only modify
1294         the start min or end min.
1295        """
1296        return _pywrapcp.Solver_IntervalRelaxedMax(self, interval_var)

Creates and returns an interval variable that wraps around the given one, relaxing the max start and end. Relaxing means making unbounded when optional. If the variable is non optional, this method returns interval_var.

More precisely, such an interval variable behaves as follows: When the underlying must be performed, the returned interval variable behaves exactly as the underlying; When the underlying may or may not be performed, the returned interval variable behaves like the underlying, except that it is unbounded on the max side; When the underlying cannot be performed, the returned interval variable is of duration 0 and must be performed in an interval unbounded on both sides.

This is very useful for implementing propagators that may only modify the start min or end min.

def TemporalDisjunction(self, *args):
1298    def TemporalDisjunction(self, *args):
1299        r"""
1300        *Overload 1:*
1301        This constraint implements a temporal disjunction between two
1302        interval vars t1 and t2. 'alt' indicates which alternative was
1303        chosen (alt == 0 is equivalent to t1 before t2).
1304
1305        |
1306
1307        *Overload 2:*
1308        This constraint implements a temporal disjunction between two
1309        interval vars.
1310        """
1311        return _pywrapcp.Solver_TemporalDisjunction(self, *args)

Overload 1: This constraint implements a temporal disjunction between two interval vars t1 and t2. 'alt' indicates which alternative was chosen (alt == 0 is equivalent to t1 before t2).

|

Overload 2: This constraint implements a temporal disjunction between two interval vars.

def DisjunctiveConstraint(self, intervals, name):
1313    def DisjunctiveConstraint(self, intervals, name):
1314        r"""
1315        This constraint forces all interval vars into an non-overlapping
1316        sequence. Intervals with zero duration can be scheduled anywhere.
1317        """
1318        return _pywrapcp.Solver_DisjunctiveConstraint(self, intervals, name)

This constraint forces all interval vars into an non-overlapping sequence. Intervals with zero duration can be scheduled anywhere.

def Cumulative(self, *args):
1320    def Cumulative(self, *args):
1321        r"""
1322        *Overload 1:*
1323        This constraint forces that, for any integer t, the sum of the demands
1324        corresponding to an interval containing t does not exceed the given
1325        capacity.
1326
1327        Intervals and demands should be vectors of equal size.
1328
1329        Demands should only contain non-negative values. Zero values are
1330        supported, and the corresponding intervals are filtered out, as they
1331        neither impact nor are impacted by this constraint.
1332
1333        |
1334
1335        *Overload 2:*
1336        This constraint forces that, for any integer t, the sum of the demands
1337        corresponding to an interval containing t does not exceed the given
1338        capacity.
1339
1340        Intervals and demands should be vectors of equal size.
1341
1342        Demands should only contain non-negative values. Zero values are
1343        supported, and the corresponding intervals are filtered out, as they
1344        neither impact nor are impacted by this constraint.
1345
1346        |
1347
1348        *Overload 3:*
1349        This constraint forces that, for any integer t, the sum of the demands
1350        corresponding to an interval containing t does not exceed the given
1351        capacity.
1352
1353        Intervals and demands should be vectors of equal size.
1354
1355        Demands should only contain non-negative values. Zero values are
1356        supported, and the corresponding intervals are filtered out, as they
1357        neither impact nor are impacted by this constraint.
1358
1359        |
1360
1361        *Overload 4:*
1362        This constraint enforces that, for any integer t, the sum of the demands
1363        corresponding to an interval containing t does not exceed the given
1364        capacity.
1365
1366        Intervals and demands should be vectors of equal size.
1367
1368        Demands should only contain non-negative values. Zero values are
1369        supported, and the corresponding intervals are filtered out, as they
1370        neither impact nor are impacted by this constraint.
1371
1372        |
1373
1374        *Overload 5:*
1375        This constraint enforces that, for any integer t, the sum of demands
1376        corresponding to an interval containing t does not exceed the given
1377        capacity.
1378
1379        Intervals and demands should be vectors of equal size.
1380
1381        Demands should be positive.
1382
1383        |
1384
1385        *Overload 6:*
1386        This constraint enforces that, for any integer t, the sum of demands
1387        corresponding to an interval containing t does not exceed the given
1388        capacity.
1389
1390        Intervals and demands should be vectors of equal size.
1391
1392        Demands should be positive.
1393        """
1394        return _pywrapcp.Solver_Cumulative(self, *args)

Overload 1: This constraint forces that, for any integer t, the sum of the demands corresponding to an interval containing t does not exceed the given capacity.

Intervals and demands should be vectors of equal size.

Demands should only contain non-negative values. Zero values are supported, and the corresponding intervals are filtered out, as they neither impact nor are impacted by this constraint.

|

Overload 2: This constraint forces that, for any integer t, the sum of the demands corresponding to an interval containing t does not exceed the given capacity.

Intervals and demands should be vectors of equal size.

Demands should only contain non-negative values. Zero values are supported, and the corresponding intervals are filtered out, as they neither impact nor are impacted by this constraint.

|

Overload 3: This constraint forces that, for any integer t, the sum of the demands corresponding to an interval containing t does not exceed the given capacity.

Intervals and demands should be vectors of equal size.

Demands should only contain non-negative values. Zero values are supported, and the corresponding intervals are filtered out, as they neither impact nor are impacted by this constraint.

|

Overload 4: This constraint enforces that, for any integer t, the sum of the demands corresponding to an interval containing t does not exceed the given capacity.

Intervals and demands should be vectors of equal size.

Demands should only contain non-negative values. Zero values are supported, and the corresponding intervals are filtered out, as they neither impact nor are impacted by this constraint.

|

Overload 5: This constraint enforces that, for any integer t, the sum of demands corresponding to an interval containing t does not exceed the given capacity.

Intervals and demands should be vectors of equal size.

Demands should be positive.

|

Overload 6: This constraint enforces that, for any integer t, the sum of demands corresponding to an interval containing t does not exceed the given capacity.

Intervals and demands should be vectors of equal size.

Demands should be positive.

def Cover(self, vars, target_var):
1396    def Cover(self, vars, target_var):
1397        r"""
1398        This constraint states that the target_var is the convex hull of
1399        the intervals. If none of the interval variables is performed,
1400        then the target var is unperformed too. Also, if the target
1401        variable is unperformed, then all the intervals variables are
1402        unperformed too.
1403        """
1404        return _pywrapcp.Solver_Cover(self, vars, target_var)

This constraint states that the target_var is the convex hull of the intervals. If none of the interval variables is performed, then the target var is unperformed too. Also, if the target variable is unperformed, then all the intervals variables are unperformed too.

def Assignment(self, *args):
1406    def Assignment(self, *args):
1407        r"""
1408        *Overload 1:*
1409        This method creates an empty assignment.
1410
1411        |
1412
1413        *Overload 2:*
1414        This method creates an assignment which is a copy of 'a'.
1415        """
1416        return _pywrapcp.Solver_Assignment(self, *args)

Overload 1: This method creates an empty assignment.

|

Overload 2: This method creates an assignment which is a copy of 'a'.

def FirstSolutionCollector(self, *args):
1418    def FirstSolutionCollector(self, *args):
1419        r"""
1420        *Overload 1:*
1421        Collect the first solution of the search.
1422
1423        |
1424
1425        *Overload 2:*
1426        Collect the first solution of the search. The variables will need to
1427        be added later.
1428        """
1429        return _pywrapcp.Solver_FirstSolutionCollector(self, *args)

Overload 1: Collect the first solution of the search.

|

Overload 2: Collect the first solution of the search. The variables will need to be added later.

def LastSolutionCollector(self, *args):
1431    def LastSolutionCollector(self, *args):
1432        r"""
1433        *Overload 1:*
1434        Collect the last solution of the search.
1435
1436        |
1437
1438        *Overload 2:*
1439        Collect the last solution of the search. The variables will need to
1440        be added later.
1441        """
1442        return _pywrapcp.Solver_LastSolutionCollector(self, *args)

Overload 1: Collect the last solution of the search.

|

Overload 2: Collect the last solution of the search. The variables will need to be added later.

def BestValueSolutionCollector(self, *args):
1444    def BestValueSolutionCollector(self, *args):
1445        r"""
1446        *Overload 1:*
1447        Collect the solution corresponding to the optimal value of the objective
1448        of 'assignment'; if 'assignment' does not have an objective no solution is
1449        collected. This collector only collects one solution corresponding to the
1450        best objective value (the first one found).
1451
1452        |
1453
1454        *Overload 2:*
1455        Collect the solution corresponding to the optimal value of the
1456        objective of 'assignment'; if 'assignment' does not have an objective no
1457        solution is collected. This collector only collects one solution
1458        corresponding to the best objective value (the first one
1459        found). The variables will need to be added later.
1460        """
1461        return _pywrapcp.Solver_BestValueSolutionCollector(self, *args)

Overload 1: Collect the solution corresponding to the optimal value of the objective of 'assignment'; if 'assignment' does not have an objective no solution is collected. This collector only collects one solution corresponding to the best objective value (the first one found).

|

Overload 2: Collect the solution corresponding to the optimal value of the objective of 'assignment'; if 'assignment' does not have an objective no solution is collected. This collector only collects one solution corresponding to the best objective value (the first one found). The variables will need to be added later.

def AllSolutionCollector(self, *args):
1463    def AllSolutionCollector(self, *args):
1464        r"""
1465        *Overload 1:*
1466        Collect all solutions of the search.
1467
1468        |
1469
1470        *Overload 2:*
1471        Collect all solutions of the search. The variables will need to
1472        be added later.
1473        """
1474        return _pywrapcp.Solver_AllSolutionCollector(self, *args)

Overload 1: Collect all solutions of the search.

|

Overload 2: Collect all solutions of the search. The variables will need to be added later.

def Minimize(self, v, step):
1476    def Minimize(self, v, step):
1477        r""" Creates a minimization objective."""
1478        return _pywrapcp.Solver_Minimize(self, v, step)

Creates a minimization objective.

def Maximize(self, v, step):
1480    def Maximize(self, v, step):
1481        r""" Creates a maximization objective."""
1482        return _pywrapcp.Solver_Maximize(self, v, step)

Creates a maximization objective.

def Optimize(self, maximize, v, step):
1484    def Optimize(self, maximize, v, step):
1485        r""" Creates a objective with a given sense (true = maximization)."""
1486        return _pywrapcp.Solver_Optimize(self, maximize, v, step)

Creates a objective with a given sense (true = maximization).

def WeightedMinimize(self, *args):
1488    def WeightedMinimize(self, *args):
1489        r"""
1490        *Overload 1:*
1491        Creates a minimization weighted objective. The actual objective is
1492        scalar_prod(sub_objectives, weights).
1493
1494        |
1495
1496        *Overload 2:*
1497        Creates a minimization weighted objective. The actual objective is
1498        scalar_prod(sub_objectives, weights).
1499        """
1500        return _pywrapcp.Solver_WeightedMinimize(self, *args)

Overload 1: Creates a minimization weighted objective. The actual objective is scalar_prod(sub_objectives, weights).

|

Overload 2: Creates a minimization weighted objective. The actual objective is scalar_prod(sub_objectives, weights).

def WeightedMaximize(self, *args):
1502    def WeightedMaximize(self, *args):
1503        r"""
1504        *Overload 1:*
1505        Creates a maximization weigthed objective.
1506
1507        |
1508
1509        *Overload 2:*
1510        Creates a maximization weigthed objective.
1511        """
1512        return _pywrapcp.Solver_WeightedMaximize(self, *args)

Overload 1: Creates a maximization weigthed objective.

|

Overload 2: Creates a maximization weigthed objective.

def WeightedOptimize(self, *args):
1514    def WeightedOptimize(self, *args):
1515        r"""
1516        *Overload 1:*
1517        Creates a weighted objective with a given sense (true = maximization).
1518
1519        |
1520
1521        *Overload 2:*
1522        Creates a weighted objective with a given sense (true = maximization).
1523        """
1524        return _pywrapcp.Solver_WeightedOptimize(self, *args)

Overload 1: Creates a weighted objective with a given sense (true = maximization).

|

Overload 2: Creates a weighted objective with a given sense (true = maximization).

def TabuSearch( self, maximize, v, step, vars, keep_tenure, forbid_tenure, tabu_factor):
1526    def TabuSearch(self, maximize, v, step, vars, keep_tenure, forbid_tenure, tabu_factor):
1527        r"""
1528        MetaHeuristics which try to get the search out of local optima.
1529        Creates a Tabu Search monitor.
1530        In the context of local search the behavior is similar to MakeOptimize(),
1531        creating an objective in a given sense. The behavior differs once a local
1532        optimum is reached: thereafter solutions which degrade the value of the
1533        objective are allowed if they are not "tabu". A solution is "tabu" if it
1534        doesn't respect the following rules:
1535        - improving the best solution found so far
1536        - variables in the "keep" list must keep their value, variables in the
1537        "forbid" list must not take the value they have in the list.
1538        Variables with new values enter the tabu lists after each new solution
1539        found and leave the lists after a given number of iterations (called
1540        tenure). Only the variables passed to the method can enter the lists.
1541        The tabu criterion is softened by the tabu factor which gives the number
1542        of "tabu" violations which is tolerated; a factor of 1 means no violations
1543        allowed; a factor of 0 means all violations are allowed.
1544        """
1545        return _pywrapcp.Solver_TabuSearch(self, maximize, v, step, vars, keep_tenure, forbid_tenure, tabu_factor)

MetaHeuristics which try to get the search out of local optima. Creates a Tabu Search monitor. In the context of local search the behavior is similar to MakeOptimize(), creating an objective in a given sense. The behavior differs once a local optimum is reached: thereafter solutions which degrade the value of the objective are allowed if they are not "tabu". A solution is "tabu" if it doesn't respect the following rules:

  • improving the best solution found so far
  • variables in the "keep" list must keep their value, variables in the "forbid" list must not take the value they have in the list. Variables with new values enter the tabu lists after each new solution found and leave the lists after a given number of iterations (called tenure). Only the variables passed to the method can enter the lists. The tabu criterion is softened by the tabu factor which gives the number of "tabu" violations which is tolerated; a factor of 1 means no violations allowed; a factor of 0 means all violations are allowed.
def SimulatedAnnealing(self, maximize, v, step, initial_temperature):
1547    def SimulatedAnnealing(self, maximize, v, step, initial_temperature):
1548        r""" Creates a Simulated Annealing monitor."""
1549        return _pywrapcp.Solver_SimulatedAnnealing(self, maximize, v, step, initial_temperature)

Creates a Simulated Annealing monitor.

def LubyRestart(self, scale_factor):
1551    def LubyRestart(self, scale_factor):
1552        r"""
1553        This search monitor will restart the search periodically.
1554        At the iteration n, it will restart after scale_factor * Luby(n) failures
1555        where Luby is the Luby Strategy (i.e. 1 1 2 1 1 2 4 1 1 2 1 1 2 4 8...).
1556        """
1557        return _pywrapcp.Solver_LubyRestart(self, scale_factor)

This search monitor will restart the search periodically. At the iteration n, it will restart after scale_factor * Luby(n) failures where Luby is the Luby Strategy (i.e. 1 1 2 1 1 2 4 1 1 2 1 1 2 4 8...).

def ConstantRestart(self, frequency):
1559    def ConstantRestart(self, frequency):
1560        r"""
1561        This search monitor will restart the search periodically after 'frequency'
1562        failures.
1563        """
1564        return _pywrapcp.Solver_ConstantRestart(self, frequency)

This search monitor will restart the search periodically after 'frequency' failures.

def TimeLimit(self, *args):
1566    def TimeLimit(self, *args):
1567        return _pywrapcp.Solver_TimeLimit(self, *args)
def BranchesLimit(self, branches):
1569    def BranchesLimit(self, branches):
1570        r"""
1571        Creates a search limit that constrains the number of branches
1572        explored in the search tree.
1573        """
1574        return _pywrapcp.Solver_BranchesLimit(self, branches)

Creates a search limit that constrains the number of branches explored in the search tree.

def FailuresLimit(self, failures):
1576    def FailuresLimit(self, failures):
1577        r"""
1578        Creates a search limit that constrains the number of failures
1579        that can happen when exploring the search tree.
1580        """
1581        return _pywrapcp.Solver_FailuresLimit(self, failures)

Creates a search limit that constrains the number of failures that can happen when exploring the search tree.

def SolutionsLimit(self, solutions):
1583    def SolutionsLimit(self, solutions):
1584        r"""
1585        Creates a search limit that constrains the number of solutions found
1586        during the search.
1587        """
1588        return _pywrapcp.Solver_SolutionsLimit(self, solutions)

Creates a search limit that constrains the number of solutions found during the search.

def Limit(self, *args):
1590    def Limit(self, *args):
1591        r"""
1592        *Overload 1:*
1593        Limits the search with the 'time', 'branches', 'failures' and
1594        'solutions' limits. 'smart_time_check' reduces the calls to the wall
1595
1596        |
1597
1598        *Overload 2:*
1599        Creates a search limit from its protobuf description
1600
1601        |
1602
1603        *Overload 3:*
1604        Creates a search limit that is reached when either of the underlying limit
1605        is reached. That is, the returned limit is more stringent than both
1606        argument limits.
1607        """
1608        return _pywrapcp.Solver_Limit(self, *args)

Overload 1: Limits the search with the 'time', 'branches', 'failures' and 'solutions' limits. 'smart_time_check' reduces the calls to the wall

|

Overload 2: Creates a search limit from its protobuf description

|

Overload 3: Creates a search limit that is reached when either of the underlying limit is reached. That is, the returned limit is more stringent than both argument limits.

def CustomLimit(self, limiter):
1610    def CustomLimit(self, limiter):
1611        r"""
1612        Callback-based search limit. Search stops when limiter returns true; if
1613        this happens at a leaf the corresponding solution will be rejected.
1614        """
1615        return _pywrapcp.Solver_CustomLimit(self, limiter)

Callback-based search limit. Search stops when limiter returns true; if this happens at a leaf the corresponding solution will be rejected.

def SearchLog(self, *args):
1617    def SearchLog(self, *args):
1618        return _pywrapcp.Solver_SearchLog(self, *args)
def SearchTrace(self, prefix):
1620    def SearchTrace(self, prefix):
1621        r"""
1622        Creates a search monitor that will trace precisely the behavior of the
1623        search. Use this only for low level debugging.
1624        """
1625        return _pywrapcp.Solver_SearchTrace(self, prefix)

Creates a search monitor that will trace precisely the behavior of the search. Use this only for low level debugging.

def PrintModelVisitor(self):
1627    def PrintModelVisitor(self):
1628        r""" Prints the model."""
1629        return _pywrapcp.Solver_PrintModelVisitor(self)

Prints the model.

def StatisticsModelVisitor(self):
1631    def StatisticsModelVisitor(self):
1632        r""" Displays some nice statistics on the model."""
1633        return _pywrapcp.Solver_StatisticsModelVisitor(self)

Displays some nice statistics on the model.

def AssignVariableValue(self, var, val):
1635    def AssignVariableValue(self, var, val):
1636        r""" Decisions."""
1637        return _pywrapcp.Solver_AssignVariableValue(self, var, val)

Decisions.

def VariableLessOrEqualValue(self, var, value):
1639    def VariableLessOrEqualValue(self, var, value):
1640        return _pywrapcp.Solver_VariableLessOrEqualValue(self, var, value)
def VariableGreaterOrEqualValue(self, var, value):
1642    def VariableGreaterOrEqualValue(self, var, value):
1643        return _pywrapcp.Solver_VariableGreaterOrEqualValue(self, var, value)
def SplitVariableDomain(self, var, val, start_with_lower_half):
1645    def SplitVariableDomain(self, var, val, start_with_lower_half):
1646        return _pywrapcp.Solver_SplitVariableDomain(self, var, val, start_with_lower_half)
def AssignVariableValueOrFail(self, var, value):
1648    def AssignVariableValueOrFail(self, var, value):
1649        return _pywrapcp.Solver_AssignVariableValueOrFail(self, var, value)
def AssignVariablesValues(self, vars, values):
1651    def AssignVariablesValues(self, vars, values):
1652        return _pywrapcp.Solver_AssignVariablesValues(self, vars, values)
def FailDecision(self):
1654    def FailDecision(self):
1655        return _pywrapcp.Solver_FailDecision(self)
def Decision(self, apply, refute):
1657    def Decision(self, apply, refute):
1658        return _pywrapcp.Solver_Decision(self, apply, refute)
def Compose(self, dbs):
1660    def Compose(self, dbs):
1661        return _pywrapcp.Solver_Compose(self, dbs)
def Try(self, dbs):
1663    def Try(self, dbs):
1664        return _pywrapcp.Solver_Try(self, dbs)
def DefaultPhase(self, *args):
1666    def DefaultPhase(self, *args):
1667        return _pywrapcp.Solver_DefaultPhase(self, *args)
def ScheduleOrPostpone(self, var, est, marker):
1669    def ScheduleOrPostpone(self, var, est, marker):
1670        r"""
1671        Returns a decision that tries to schedule a task at a given time.
1672        On the Apply branch, it will set that interval var as performed and set
1673        its start to 'est'. On the Refute branch, it will just update the
1674        'marker' to 'est' + 1. This decision is used in the
1675        INTERVAL_SET_TIMES_FORWARD strategy.
1676        """
1677        return _pywrapcp.Solver_ScheduleOrPostpone(self, var, est, marker)

Returns a decision that tries to schedule a task at a given time. On the Apply branch, it will set that interval var as performed and set its start to 'est'. On the Refute branch, it will just update the 'marker' to 'est' + 1. This decision is used in the INTERVAL_SET_TIMES_FORWARD strategy.

def ScheduleOrExpedite(self, var, est, marker):
1679    def ScheduleOrExpedite(self, var, est, marker):
1680        r"""
1681        Returns a decision that tries to schedule a task at a given time.
1682        On the Apply branch, it will set that interval var as performed and set
1683        its end to 'est'. On the Refute branch, it will just update the
1684        'marker' to 'est' - 1. This decision is used in the
1685        INTERVAL_SET_TIMES_BACKWARD strategy.
1686        """
1687        return _pywrapcp.Solver_ScheduleOrExpedite(self, var, est, marker)

Returns a decision that tries to schedule a task at a given time. On the Apply branch, it will set that interval var as performed and set its end to 'est'. On the Refute branch, it will just update the 'marker' to 'est' - 1. This decision is used in the INTERVAL_SET_TIMES_BACKWARD strategy.

def RankFirstInterval(self, sequence, index):
1689    def RankFirstInterval(self, sequence, index):
1690        r"""
1691        Returns a decision that tries to rank first the ith interval var
1692        in the sequence variable.
1693        """
1694        return _pywrapcp.Solver_RankFirstInterval(self, sequence, index)

Returns a decision that tries to rank first the ith interval var in the sequence variable.

def RankLastInterval(self, sequence, index):
1696    def RankLastInterval(self, sequence, index):
1697        r"""
1698        Returns a decision that tries to rank last the ith interval var
1699        in the sequence variable.
1700        """
1701        return _pywrapcp.Solver_RankLastInterval(self, sequence, index)

Returns a decision that tries to rank last the ith interval var in the sequence variable.

def Phase(self, *args):
1703    def Phase(self, *args):
1704        return _pywrapcp.Solver_Phase(self, *args)
def DecisionBuilderFromAssignment(self, assignment, db, vars):
1706    def DecisionBuilderFromAssignment(self, assignment, db, vars):
1707        r"""
1708        Returns a decision builder for which the left-most leaf corresponds
1709        to assignment, the rest of the tree being explored using 'db'.
1710        """
1711        return _pywrapcp.Solver_DecisionBuilderFromAssignment(self, assignment, db, vars)

Returns a decision builder for which the left-most leaf corresponds to assignment, the rest of the tree being explored using 'db'.

def ConstraintAdder(self, ct):
1713    def ConstraintAdder(self, ct):
1714        r"""
1715        Returns a decision builder that will add the given constraint to
1716        the model.
1717        """
1718        return _pywrapcp.Solver_ConstraintAdder(self, ct)

Returns a decision builder that will add the given constraint to the model.

def SolveOnce(self, db, monitors):
1720    def SolveOnce(self, db, monitors):
1721        return _pywrapcp.Solver_SolveOnce(self, db, monitors)
def NestedOptimize(self, *args):
1723    def NestedOptimize(self, *args):
1724        return _pywrapcp.Solver_NestedOptimize(self, *args)
def RestoreAssignment(self, assignment):
1726    def RestoreAssignment(self, assignment):
1727        r"""
1728        Returns a DecisionBuilder which restores an Assignment
1729        (calls void Assignment::Restore())
1730        """
1731        return _pywrapcp.Solver_RestoreAssignment(self, assignment)

Returns a DecisionBuilder which restores an Assignment (calls void Assignment::Restore())

def StoreAssignment(self, assignment):
1733    def StoreAssignment(self, assignment):
1734        r"""
1735        Returns a DecisionBuilder which stores an Assignment
1736        (calls void Assignment::Store())
1737        """
1738        return _pywrapcp.Solver_StoreAssignment(self, assignment)

Returns a DecisionBuilder which stores an Assignment (calls void Assignment::Store())

def Operator(self, *args):
1740    def Operator(self, *args):
1741        return _pywrapcp.Solver_Operator(self, *args)
def RandomLnsOperator(self, *args):
1743    def RandomLnsOperator(self, *args):
1744        return _pywrapcp.Solver_RandomLnsOperator(self, *args)
def MoveTowardTargetOperator(self, *args):
1746    def MoveTowardTargetOperator(self, *args):
1747        r"""
1748        *Overload 1:*
1749        Creates a local search operator that tries to move the assignment of some
1750        variables toward a target. The target is given as an Assignment. This
1751        operator generates neighbors in which the only difference compared to the
1752        current state is that one variable that belongs to the target assignment
1753        is set to its target value.
1754
1755        |
1756
1757        *Overload 2:*
1758        Creates a local search operator that tries to move the assignment of some
1759        variables toward a target. The target is given either as two vectors: a
1760        vector of variables and a vector of associated target values. The two
1761        vectors should be of the same length. This operator generates neighbors in
1762        which the only difference compared to the current state is that one
1763        variable that belongs to the given vector is set to its target value.
1764        """
1765        return _pywrapcp.Solver_MoveTowardTargetOperator(self, *args)

Overload 1: Creates a local search operator that tries to move the assignment of some variables toward a target. The target is given as an Assignment. This operator generates neighbors in which the only difference compared to the current state is that one variable that belongs to the target assignment is set to its target value.

|

Overload 2: Creates a local search operator that tries to move the assignment of some variables toward a target. The target is given either as two vectors: a vector of variables and a vector of associated target values. The two vectors should be of the same length. This operator generates neighbors in which the only difference compared to the current state is that one variable that belongs to the given vector is set to its target value.

def ConcatenateOperators(self, *args):
1767    def ConcatenateOperators(self, *args):
1768        return _pywrapcp.Solver_ConcatenateOperators(self, *args)
def RandomConcatenateOperators(self, *args):
1770    def RandomConcatenateOperators(self, *args):
1771        r"""
1772        *Overload 1:*
1773        Randomized version of local search concatenator; calls a random operator
1774        at each call to MakeNextNeighbor().
1775
1776        |
1777
1778        *Overload 2:*
1779        Randomized version of local search concatenator; calls a random operator
1780        at each call to MakeNextNeighbor(). The provided seed is used to
1781        initialize the random number generator.
1782        """
1783        return _pywrapcp.Solver_RandomConcatenateOperators(self, *args)

Overload 1: Randomized version of local search concatenator; calls a random operator at each call to MakeNextNeighbor().

|

Overload 2: Randomized version of local search concatenator; calls a random operator at each call to MakeNextNeighbor(). The provided seed is used to initialize the random number generator.

def NeighborhoodLimit(self, op, limit):
1785    def NeighborhoodLimit(self, op, limit):
1786        r"""
1787        Creates a local search operator that wraps another local search
1788        operator and limits the number of neighbors explored (i.e., calls
1789        to MakeNextNeighbor from the current solution (between two calls
1790        to Start()). When this limit is reached, MakeNextNeighbor()
1791        returns false. The counter is cleared when Start() is called.
1792        """
1793        return _pywrapcp.Solver_NeighborhoodLimit(self, op, limit)

Creates a local search operator that wraps another local search operator and limits the number of neighbors explored (i.e., calls to MakeNextNeighbor from the current solution (between two calls to Start()). When this limit is reached, MakeNextNeighbor() returns false. The counter is cleared when Start() is called.

def LocalSearchPhase(self, *args):
1795    def LocalSearchPhase(self, *args):
1796        return _pywrapcp.Solver_LocalSearchPhase(self, *args)
def LocalSearchPhaseParameters(self, *args):
1798    def LocalSearchPhaseParameters(self, *args):
1799        return _pywrapcp.Solver_LocalSearchPhaseParameters(self, *args)
def SearchDepth(self):
1801    def SearchDepth(self):
1802        r"""
1803        Gets the search depth of the current active search. Returns -1 if
1804        there is no active search opened.
1805        """
1806        return _pywrapcp.Solver_SearchDepth(self)

Gets the search depth of the current active search. Returns -1 if there is no active search opened.

def SearchLeftDepth(self):
1808    def SearchLeftDepth(self):
1809        r"""
1810        Gets the search left depth of the current active search. Returns -1 if
1811        there is no active search opened.
1812        """
1813        return _pywrapcp.Solver_SearchLeftDepth(self)

Gets the search left depth of the current active search. Returns -1 if there is no active search opened.

def SolveDepth(self):
1815    def SolveDepth(self):
1816        r"""
1817        Gets the number of nested searches. It returns 0 outside search,
1818        1 during the top level search, 2 or more in case of nested searches.
1819        """
1820        return _pywrapcp.Solver_SolveDepth(self)

Gets the number of nested searches. It returns 0 outside search, 1 during the top level search, 2 or more in case of nested searches.

def Rand64(self, size):
1822    def Rand64(self, size):
1823        r""" Returns a random value between 0 and 'size' - 1;"""
1824        return _pywrapcp.Solver_Rand64(self, size)

Returns a random value between 0 and 'size' - 1;

def Rand32(self, size):
1826    def Rand32(self, size):
1827        r""" Returns a random value between 0 and 'size' - 1;"""
1828        return _pywrapcp.Solver_Rand32(self, size)

Returns a random value between 0 and 'size' - 1;

def ReSeed(self, seed):
1830    def ReSeed(self, seed):
1831        r""" Reseed the solver random generator."""
1832        return _pywrapcp.Solver_ReSeed(self, seed)

Reseed the solver random generator.

def LocalSearchProfile(self):
1834    def LocalSearchProfile(self):
1835        r""" Returns local search profiling information in a human readable format."""
1836        return _pywrapcp.Solver_LocalSearchProfile(self)

Returns local search profiling information in a human readable format.

def Constraints(self):
1838    def Constraints(self):
1839        r"""
1840        Counts the number of constraints that have been added
1841        to the solver before the search.
1842        """
1843        return _pywrapcp.Solver_Constraints(self)

Counts the number of constraints that have been added to the solver before the search.

def Accept(self, visitor):
1845    def Accept(self, visitor):
1846        r""" Accepts the given model visitor."""
1847        return _pywrapcp.Solver_Accept(self, visitor)

Accepts the given model visitor.

def FinishCurrentSearch(self):
1849    def FinishCurrentSearch(self):
1850        r""" Tells the solver to kill or restart the current search."""
1851        return _pywrapcp.Solver_FinishCurrentSearch(self)

Tells the solver to kill or restart the current search.

def RestartCurrentSearch(self):
1853    def RestartCurrentSearch(self):
1854        return _pywrapcp.Solver_RestartCurrentSearch(self)
def ShouldFail(self):
1856    def ShouldFail(self):
1857        r"""
1858        These methods are only useful for the SWIG wrappers, which need a way
1859        to externally cause the Solver to fail.
1860        """
1861        return _pywrapcp.Solver_ShouldFail(self)

These methods are only useful for the SWIG wrappers, which need a way to externally cause the Solver to fail.

def Add(self, ct):
1866    def Add(self, ct):
1867      if isinstance(ct, PyConstraint):
1868        self.__python_constraints.append(ct)
1869      self.AddConstraint(ct)
def TreeNoCycle(self, nexts, active, callback=0):
1872    def TreeNoCycle(self, nexts, active, callback=0):
1873        return _pywrapcp.Solver_TreeNoCycle(self, nexts, active, callback)
def SearchLogWithCallback(self, period, callback):
1875    def SearchLogWithCallback(self, period, callback):
1876        return _pywrapcp.Solver_SearchLogWithCallback(self, period, callback)
def ElementFunction(self, values, index):
1878    def ElementFunction(self, values, index):
1879        return _pywrapcp.Solver_ElementFunction(self, values, index)
def VarEvalValStrPhase(self, vars, var_evaluator, val_str):
1881    def VarEvalValStrPhase(self, vars, var_evaluator, val_str):
1882        return _pywrapcp.Solver_VarEvalValStrPhase(self, vars, var_evaluator, val_str)
def VarStrValEvalPhase(self, vars, var_str, val_eval):
1884    def VarStrValEvalPhase(self, vars, var_str, val_eval):
1885        return _pywrapcp.Solver_VarStrValEvalPhase(self, vars, var_str, val_eval)
def VarEvalValEvalPhase(self, vars, var_eval, val_eval):
1887    def VarEvalValEvalPhase(self, vars, var_eval, val_eval):
1888        return _pywrapcp.Solver_VarEvalValEvalPhase(self, vars, var_eval, val_eval)
def VarStrValEvalTieBreakPhase(self, vars, var_str, val_eval, tie_breaker):
1890    def VarStrValEvalTieBreakPhase(self, vars, var_str, val_eval, tie_breaker):
1891        return _pywrapcp.Solver_VarStrValEvalTieBreakPhase(self, vars, var_str, val_eval, tie_breaker)
def VarEvalValEvalTieBreakPhase(self, vars, var_eval, val_eval, tie_breaker):
1893    def VarEvalValEvalTieBreakPhase(self, vars, var_eval, val_eval, tie_breaker):
1894        return _pywrapcp.Solver_VarEvalValEvalTieBreakPhase(self, vars, var_eval, val_eval, tie_breaker)
def EvalEvalStrPhase(self, vars, evaluator, str):
1896    def EvalEvalStrPhase(self, vars, evaluator, str):
1897        return _pywrapcp.Solver_EvalEvalStrPhase(self, vars, evaluator, str)
def EvalEvalStrTieBreakPhase(self, vars, evaluator, tie_breaker, str):
1899    def EvalEvalStrTieBreakPhase(self, vars, evaluator, tie_breaker, str):
1900        return _pywrapcp.Solver_EvalEvalStrTieBreakPhase(self, vars, evaluator, tie_breaker, str)
def GuidedLocalSearch(self, *args):
1902    def GuidedLocalSearch(self, *args):
1903        return _pywrapcp.Solver_GuidedLocalSearch(self, *args)
def SumObjectiveFilter(self, vars, values, filter_enum):
1905    def SumObjectiveFilter(self, vars, values, filter_enum):
1906        return _pywrapcp.Solver_SumObjectiveFilter(self, vars, values, filter_enum)
class BaseObject:
1910class BaseObject(object):
1911    r"""
1912    A BaseObject is the root of all reversibly allocated objects.
1913    A DebugString method and the associated << operator are implemented
1914    as a convenience.
1915    """
1916
1917    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
1918
1919    def __init__(self):
1920        if self.__class__ == BaseObject:
1921            _self = None
1922        else:
1923            _self = self
1924        _pywrapcp.BaseObject_swiginit(self, _pywrapcp.new_BaseObject(_self, ))
1925    __swig_destroy__ = _pywrapcp.delete_BaseObject
1926
1927    def DebugString(self):
1928        return _pywrapcp.BaseObject_DebugString(self)
1929
1930    def __str__(self):
1931        return _pywrapcp.BaseObject___str__(self)
1932
1933    def __repr__(self):
1934        return _pywrapcp.BaseObject___repr__(self)
1935    def __disown__(self):
1936        self.this.disown()
1937        _pywrapcp.disown_BaseObject(self)
1938        return weakref.proxy(self)

A BaseObject is the root of all reversibly allocated objects. A DebugString method and the associated << operator are implemented as a convenience.

BaseObject()
1919    def __init__(self):
1920        if self.__class__ == BaseObject:
1921            _self = None
1922        else:
1923            _self = self
1924        _pywrapcp.BaseObject_swiginit(self, _pywrapcp.new_BaseObject(_self, ))
thisown

The membership flag

def DebugString(self):
1927    def DebugString(self):
1928        return _pywrapcp.BaseObject_DebugString(self)
class PropagationBaseObject(BaseObject):
1942class PropagationBaseObject(BaseObject):
1943    r"""
1944    NOLINT
1945    The PropagationBaseObject is a subclass of BaseObject that is also
1946    friend to the Solver class. It allows accessing methods useful when
1947    writing new constraints or new expressions.
1948    """
1949
1950    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
1951    __repr__ = _swig_repr
1952
1953    def __init__(self, s):
1954        if self.__class__ == PropagationBaseObject:
1955            _self = None
1956        else:
1957            _self = self
1958        _pywrapcp.PropagationBaseObject_swiginit(self, _pywrapcp.new_PropagationBaseObject(_self, s))
1959    __swig_destroy__ = _pywrapcp.delete_PropagationBaseObject
1960
1961    def DebugString(self):
1962        return _pywrapcp.PropagationBaseObject_DebugString(self)
1963
1964    def solver(self):
1965        return _pywrapcp.PropagationBaseObject_solver(self)
1966
1967    def Name(self):
1968        r""" Object naming."""
1969        return _pywrapcp.PropagationBaseObject_Name(self)
1970    def __disown__(self):
1971        self.this.disown()
1972        _pywrapcp.disown_PropagationBaseObject(self)
1973        return weakref.proxy(self)

NOLINT The PropagationBaseObject is a subclass of BaseObject that is also friend to the Solver class. It allows accessing methods useful when writing new constraints or new expressions.

PropagationBaseObject(s)
1953    def __init__(self, s):
1954        if self.__class__ == PropagationBaseObject:
1955            _self = None
1956        else:
1957            _self = self
1958        _pywrapcp.PropagationBaseObject_swiginit(self, _pywrapcp.new_PropagationBaseObject(_self, s))
thisown

The membership flag

def DebugString(self):
1961    def DebugString(self):
1962        return _pywrapcp.PropagationBaseObject_DebugString(self)
def solver(self):
1964    def solver(self):
1965        return _pywrapcp.PropagationBaseObject_solver(self)
def Name(self):
1967    def Name(self):
1968        r""" Object naming."""
1969        return _pywrapcp.PropagationBaseObject_Name(self)

Object naming.

class Decision(BaseObject):
1977class Decision(BaseObject):
1978    r"""
1979    A Decision represents a choice point in the search tree. The two main
1980    methods are Apply() to go left, or Refute() to go right.
1981    """
1982
1983    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
1984
1985    def __init__(self):
1986        if self.__class__ == Decision:
1987            _self = None
1988        else:
1989            _self = self
1990        _pywrapcp.Decision_swiginit(self, _pywrapcp.new_Decision(_self, ))
1991    __swig_destroy__ = _pywrapcp.delete_Decision
1992
1993    def ApplyWrapper(self, s):
1994        r""" Apply will be called first when the decision is executed."""
1995        return _pywrapcp.Decision_ApplyWrapper(self, s)
1996
1997    def RefuteWrapper(self, s):
1998        r""" Refute will be called after a backtrack."""
1999        return _pywrapcp.Decision_RefuteWrapper(self, s)
2000
2001    def DebugString(self):
2002        return _pywrapcp.Decision_DebugString(self)
2003
2004    def __repr__(self):
2005        return _pywrapcp.Decision___repr__(self)
2006
2007    def __str__(self):
2008        return _pywrapcp.Decision___str__(self)
2009    def __disown__(self):
2010        self.this.disown()
2011        _pywrapcp.disown_Decision(self)
2012        return weakref.proxy(self)

A Decision represents a choice point in the search tree. The two main methods are Apply() to go left, or Refute() to go right.

Decision()
1985    def __init__(self):
1986        if self.__class__ == Decision:
1987            _self = None
1988        else:
1989            _self = self
1990        _pywrapcp.Decision_swiginit(self, _pywrapcp.new_Decision(_self, ))
thisown

The membership flag

def ApplyWrapper(self, s):
1993    def ApplyWrapper(self, s):
1994        r""" Apply will be called first when the decision is executed."""
1995        return _pywrapcp.Decision_ApplyWrapper(self, s)

Apply will be called first when the decision is executed.

def RefuteWrapper(self, s):
1997    def RefuteWrapper(self, s):
1998        r""" Refute will be called after a backtrack."""
1999        return _pywrapcp.Decision_RefuteWrapper(self, s)

Refute will be called after a backtrack.

def DebugString(self):
2001    def DebugString(self):
2002        return _pywrapcp.Decision_DebugString(self)
class DecisionBuilder(BaseObject):
2016class DecisionBuilder(BaseObject):
2017    r"""
2018    A DecisionBuilder is responsible for creating the search tree. The
2019    important method is Next(), which returns the next decision to execute.
2020    """
2021
2022    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2023
2024    def __init__(self):
2025        if self.__class__ == DecisionBuilder:
2026            _self = None
2027        else:
2028            _self = self
2029        _pywrapcp.DecisionBuilder_swiginit(self, _pywrapcp.new_DecisionBuilder(_self, ))
2030    __swig_destroy__ = _pywrapcp.delete_DecisionBuilder
2031
2032    def NextWrapper(self, s):
2033        r"""
2034        This is the main method of the decision builder class. It must
2035        return a decision (an instance of the class Decision). If it
2036        returns nullptr, this means that the decision builder has finished
2037        its work.
2038        """
2039        return _pywrapcp.DecisionBuilder_NextWrapper(self, s)
2040
2041    def DebugString(self):
2042        return _pywrapcp.DecisionBuilder_DebugString(self)
2043
2044    def __repr__(self):
2045        return _pywrapcp.DecisionBuilder___repr__(self)
2046
2047    def __str__(self):
2048        return _pywrapcp.DecisionBuilder___str__(self)
2049    def __disown__(self):
2050        self.this.disown()
2051        _pywrapcp.disown_DecisionBuilder(self)
2052        return weakref.proxy(self)

A DecisionBuilder is responsible for creating the search tree. The important method is Next(), which returns the next decision to execute.

DecisionBuilder()
2024    def __init__(self):
2025        if self.__class__ == DecisionBuilder:
2026            _self = None
2027        else:
2028            _self = self
2029        _pywrapcp.DecisionBuilder_swiginit(self, _pywrapcp.new_DecisionBuilder(_self, ))
thisown

The membership flag

def NextWrapper(self, s):
2032    def NextWrapper(self, s):
2033        r"""
2034        This is the main method of the decision builder class. It must
2035        return a decision (an instance of the class Decision). If it
2036        returns nullptr, this means that the decision builder has finished
2037        its work.
2038        """
2039        return _pywrapcp.DecisionBuilder_NextWrapper(self, s)

This is the main method of the decision builder class. It must return a decision (an instance of the class Decision). If it returns nullptr, this means that the decision builder has finished its work.

def DebugString(self):
2041    def DebugString(self):
2042        return _pywrapcp.DecisionBuilder_DebugString(self)
class Demon(BaseObject):
2056class Demon(BaseObject):
2057    r"""
2058    A Demon is the base element of a propagation queue. It is the main
2059      object responsible for implementing the actual propagation
2060      of the constraint and pruning the inconsistent values in the domains
2061      of the variables. The main concept is that demons are listeners that are
2062      attached to the variables and listen to their modifications.
2063    There are two methods:
2064     - Run() is the actual method called when the demon is processed.
2065     - priority() returns its priority. Standard priorities are slow, normal
2066       or fast. "immediate" is reserved for variables and is treated separately.
2067    """
2068
2069    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2070    __repr__ = _swig_repr
2071
2072    def __init__(self):
2073        r"""
2074        This indicates the priority of a demon. Immediate demons are treated
2075        separately and corresponds to variables.
2076        """
2077        if self.__class__ == Demon:
2078            _self = None
2079        else:
2080            _self = self
2081        _pywrapcp.Demon_swiginit(self, _pywrapcp.new_Demon(_self, ))
2082    __swig_destroy__ = _pywrapcp.delete_Demon
2083
2084    def RunWrapper(self, s):
2085        r""" This is the main callback of the demon."""
2086        return _pywrapcp.Demon_RunWrapper(self, s)
2087
2088    def Priority(self):
2089        r"""
2090        This method returns the priority of the demon. Usually a demon is
2091        fast, slow or normal. Immediate demons are reserved for internal
2092        use to maintain variables.
2093        """
2094        return _pywrapcp.Demon_Priority(self)
2095
2096    def DebugString(self):
2097        return _pywrapcp.Demon_DebugString(self)
2098
2099    def Inhibit(self, s):
2100        r"""
2101        This method inhibits the demon in the search tree below the
2102        current position.
2103        """
2104        return _pywrapcp.Demon_Inhibit(self, s)
2105
2106    def Desinhibit(self, s):
2107        r""" This method un-inhibits the demon that was previously inhibited."""
2108        return _pywrapcp.Demon_Desinhibit(self, s)
2109    def __disown__(self):
2110        self.this.disown()
2111        _pywrapcp.disown_Demon(self)
2112        return weakref.proxy(self)

A Demon is the base element of a propagation queue. It is the main object responsible for implementing the actual propagation of the constraint and pruning the inconsistent values in the domains of the variables. The main concept is that demons are listeners that are attached to the variables and listen to their modifications.

There are two methods:
  • Run() is the actual method called when the demon is processed.
  • priority() returns its priority. Standard priorities are slow, normal or fast. "immediate" is reserved for variables and is treated separately.
Demon()
2072    def __init__(self):
2073        r"""
2074        This indicates the priority of a demon. Immediate demons are treated
2075        separately and corresponds to variables.
2076        """
2077        if self.__class__ == Demon:
2078            _self = None
2079        else:
2080            _self = self
2081        _pywrapcp.Demon_swiginit(self, _pywrapcp.new_Demon(_self, ))

This indicates the priority of a demon. Immediate demons are treated separately and corresponds to variables.

thisown

The membership flag

def RunWrapper(self, s):
2084    def RunWrapper(self, s):
2085        r""" This is the main callback of the demon."""
2086        return _pywrapcp.Demon_RunWrapper(self, s)

This is the main callback of the demon.

def Priority(self):
2088    def Priority(self):
2089        r"""
2090        This method returns the priority of the demon. Usually a demon is
2091        fast, slow or normal. Immediate demons are reserved for internal
2092        use to maintain variables.
2093        """
2094        return _pywrapcp.Demon_Priority(self)

This method returns the priority of the demon. Usually a demon is fast, slow or normal. Immediate demons are reserved for internal use to maintain variables.

def DebugString(self):
2096    def DebugString(self):
2097        return _pywrapcp.Demon_DebugString(self)
def Inhibit(self, s):
2099    def Inhibit(self, s):
2100        r"""
2101        This method inhibits the demon in the search tree below the
2102        current position.
2103        """
2104        return _pywrapcp.Demon_Inhibit(self, s)

This method inhibits the demon in the search tree below the current position.

def Desinhibit(self, s):
2106    def Desinhibit(self, s):
2107        r""" This method un-inhibits the demon that was previously inhibited."""
2108        return _pywrapcp.Demon_Desinhibit(self, s)

This method un-inhibits the demon that was previously inhibited.

class Constraint(PropagationBaseObject):
2116class Constraint(PropagationBaseObject):
2117    r"""
2118    A constraint is the main modeling object. It provides two methods:
2119      - Post() is responsible for creating the demons and attaching them to
2120        immediate demons().
2121      - InitialPropagate() is called once just after Post and performs
2122        the initial propagation. The subsequent propagations will be performed
2123        by the demons Posted during the post() method.
2124    """
2125
2126    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2127
2128    def __init__(self, solver):
2129        if self.__class__ == Constraint:
2130            _self = None
2131        else:
2132            _self = self
2133        _pywrapcp.Constraint_swiginit(self, _pywrapcp.new_Constraint(_self, solver))
2134    __swig_destroy__ = _pywrapcp.delete_Constraint
2135
2136    def Post(self):
2137        r"""
2138        This method is called when the constraint is processed by the
2139        solver. Its main usage is to attach demons to variables.
2140        """
2141        return _pywrapcp.Constraint_Post(self)
2142
2143    def InitialPropagateWrapper(self):
2144        r"""
2145        This method performs the initial propagation of the
2146        constraint. It is called just after the post.
2147        """
2148        return _pywrapcp.Constraint_InitialPropagateWrapper(self)
2149
2150    def DebugString(self):
2151        return _pywrapcp.Constraint_DebugString(self)
2152
2153    def Var(self):
2154        r"""
2155        Creates a Boolean variable representing the status of the constraint
2156        (false = constraint is violated, true = constraint is satisfied). It
2157        returns nullptr if the constraint does not support this API.
2158        """
2159        return _pywrapcp.Constraint_Var(self)
2160
2161    def __repr__(self):
2162        return _pywrapcp.Constraint___repr__(self)
2163
2164    def __str__(self):
2165        return _pywrapcp.Constraint___str__(self)
2166
2167    def __add__(self, *args):
2168        return _pywrapcp.Constraint___add__(self, *args)
2169
2170    def __radd__(self, v):
2171        return _pywrapcp.Constraint___radd__(self, v)
2172
2173    def __sub__(self, *args):
2174        return _pywrapcp.Constraint___sub__(self, *args)
2175
2176    def __rsub__(self, v):
2177        return _pywrapcp.Constraint___rsub__(self, v)
2178
2179    def __mul__(self, *args):
2180        return _pywrapcp.Constraint___mul__(self, *args)
2181
2182    def __rmul__(self, v):
2183        return _pywrapcp.Constraint___rmul__(self, v)
2184
2185    def __floordiv__(self, v):
2186        return _pywrapcp.Constraint___floordiv__(self, v)
2187
2188    def __neg__(self):
2189        return _pywrapcp.Constraint___neg__(self)
2190
2191    def __abs__(self):
2192        return _pywrapcp.Constraint___abs__(self)
2193
2194    def Square(self):
2195        return _pywrapcp.Constraint_Square(self)
2196
2197    def __eq__(self, *args):
2198        return _pywrapcp.Constraint___eq__(self, *args)
2199
2200    def __ne__(self, *args):
2201        return _pywrapcp.Constraint___ne__(self, *args)
2202
2203    def __ge__(self, *args):
2204        return _pywrapcp.Constraint___ge__(self, *args)
2205
2206    def __gt__(self, *args):
2207        return _pywrapcp.Constraint___gt__(self, *args)
2208
2209    def __le__(self, *args):
2210        return _pywrapcp.Constraint___le__(self, *args)
2211
2212    def __lt__(self, *args):
2213        return _pywrapcp.Constraint___lt__(self, *args)
2214
2215    def MapTo(self, vars):
2216        return _pywrapcp.Constraint_MapTo(self, vars)
2217
2218    def IndexOf(self, *args):
2219        return _pywrapcp.Constraint_IndexOf(self, *args)
2220    def __disown__(self):
2221        self.this.disown()
2222        _pywrapcp.disown_Constraint(self)
2223        return weakref.proxy(self)

A constraint is the main modeling object. It provides two methods:

  • Post() is responsible for creating the demons and attaching them to immediate demons().
  • InitialPropagate() is called once just after Post and performs the initial propagation. The subsequent propagations will be performed by the demons Posted during the post() method.
Constraint(solver)
2128    def __init__(self, solver):
2129        if self.__class__ == Constraint:
2130            _self = None
2131        else:
2132            _self = self
2133        _pywrapcp.Constraint_swiginit(self, _pywrapcp.new_Constraint(_self, solver))
thisown

The membership flag

def Post(self):
2136    def Post(self):
2137        r"""
2138        This method is called when the constraint is processed by the
2139        solver. Its main usage is to attach demons to variables.
2140        """
2141        return _pywrapcp.Constraint_Post(self)

This method is called when the constraint is processed by the solver. Its main usage is to attach demons to variables.

def InitialPropagateWrapper(self):
2143    def InitialPropagateWrapper(self):
2144        r"""
2145        This method performs the initial propagation of the
2146        constraint. It is called just after the post.
2147        """
2148        return _pywrapcp.Constraint_InitialPropagateWrapper(self)

This method performs the initial propagation of the constraint. It is called just after the post.

def DebugString(self):
2150    def DebugString(self):
2151        return _pywrapcp.Constraint_DebugString(self)
def Var(self):
2153    def Var(self):
2154        r"""
2155        Creates a Boolean variable representing the status of the constraint
2156        (false = constraint is violated, true = constraint is satisfied). It
2157        returns nullptr if the constraint does not support this API.
2158        """
2159        return _pywrapcp.Constraint_Var(self)

Creates a Boolean variable representing the status of the constraint (false = constraint is violated, true = constraint is satisfied). It returns nullptr if the constraint does not support this API.

def Square(self):
2194    def Square(self):
2195        return _pywrapcp.Constraint_Square(self)
def MapTo(self, vars):
2215    def MapTo(self, vars):
2216        return _pywrapcp.Constraint_MapTo(self, vars)
def IndexOf(self, *args):
2218    def IndexOf(self, *args):
2219        return _pywrapcp.Constraint_IndexOf(self, *args)
Inherited Members
PropagationBaseObject
solver
Name
class SearchMonitor(BaseObject):
2227class SearchMonitor(BaseObject):
2228    r""" A search monitor is a simple set of callbacks to monitor all search events"""
2229
2230    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2231
2232    def __init__(self, s):
2233        if self.__class__ == SearchMonitor:
2234            _self = None
2235        else:
2236            _self = self
2237        _pywrapcp.SearchMonitor_swiginit(self, _pywrapcp.new_SearchMonitor(_self, s))
2238    __swig_destroy__ = _pywrapcp.delete_SearchMonitor
2239
2240    def EnterSearch(self):
2241        r""" Beginning of the search."""
2242        return _pywrapcp.SearchMonitor_EnterSearch(self)
2243
2244    def RestartSearch(self):
2245        r""" Restart the search."""
2246        return _pywrapcp.SearchMonitor_RestartSearch(self)
2247
2248    def ExitSearch(self):
2249        r""" End of the search."""
2250        return _pywrapcp.SearchMonitor_ExitSearch(self)
2251
2252    def BeginNextDecision(self, b):
2253        r""" Before calling DecisionBuilder::Next."""
2254        return _pywrapcp.SearchMonitor_BeginNextDecision(self, b)
2255
2256    def EndNextDecision(self, b, d):
2257        r""" After calling DecisionBuilder::Next, along with the returned decision."""
2258        return _pywrapcp.SearchMonitor_EndNextDecision(self, b, d)
2259
2260    def ApplyDecision(self, d):
2261        r""" Before applying the decision."""
2262        return _pywrapcp.SearchMonitor_ApplyDecision(self, d)
2263
2264    def RefuteDecision(self, d):
2265        r""" Before refuting the decision."""
2266        return _pywrapcp.SearchMonitor_RefuteDecision(self, d)
2267
2268    def AfterDecision(self, d, apply):
2269        r"""
2270        Just after refuting or applying the decision, apply is true after Apply.
2271        This is called only if the Apply() or Refute() methods have not failed.
2272        """
2273        return _pywrapcp.SearchMonitor_AfterDecision(self, d, apply)
2274
2275    def BeginFail(self):
2276        r""" Just when the failure occurs."""
2277        return _pywrapcp.SearchMonitor_BeginFail(self)
2278
2279    def EndFail(self):
2280        r""" After completing the backtrack."""
2281        return _pywrapcp.SearchMonitor_EndFail(self)
2282
2283    def BeginInitialPropagation(self):
2284        r""" Before the initial propagation."""
2285        return _pywrapcp.SearchMonitor_BeginInitialPropagation(self)
2286
2287    def EndInitialPropagation(self):
2288        r""" After the initial propagation."""
2289        return _pywrapcp.SearchMonitor_EndInitialPropagation(self)
2290
2291    def AcceptSolution(self):
2292        r"""
2293        This method is called when a solution is found. It asserts whether the
2294        solution is valid. A value of false indicates that the solution
2295        should be discarded.
2296        """
2297        return _pywrapcp.SearchMonitor_AcceptSolution(self)
2298
2299    def AtSolution(self):
2300        r"""
2301        This method is called when a valid solution is found. If the
2302        return value is true, then search will resume after. If the result
2303        is false, then search will stop there.
2304        """
2305        return _pywrapcp.SearchMonitor_AtSolution(self)
2306
2307    def NoMoreSolutions(self):
2308        r""" When the search tree is finished."""
2309        return _pywrapcp.SearchMonitor_NoMoreSolutions(self)
2310
2311    def LocalOptimum(self):
2312        r"""
2313        When a local optimum is reached. If 'true' is returned, the last solution
2314        is discarded and the search proceeds with the next one.
2315        """
2316        return _pywrapcp.SearchMonitor_LocalOptimum(self)
2317
2318    def AcceptDelta(self, delta, deltadelta):
2319        
2320        return _pywrapcp.SearchMonitor_AcceptDelta(self, delta, deltadelta)
2321
2322    def AcceptNeighbor(self):
2323        r""" After accepting a neighbor during local search."""
2324        return _pywrapcp.SearchMonitor_AcceptNeighbor(self)
2325
2326    def solver(self):
2327        return _pywrapcp.SearchMonitor_solver(self)
2328
2329    def __repr__(self):
2330        return _pywrapcp.SearchMonitor___repr__(self)
2331
2332    def __str__(self):
2333        return _pywrapcp.SearchMonitor___str__(self)
2334    def __disown__(self):
2335        self.this.disown()
2336        _pywrapcp.disown_SearchMonitor(self)
2337        return weakref.proxy(self)

A search monitor is a simple set of callbacks to monitor all search events

SearchMonitor(s)
2232    def __init__(self, s):
2233        if self.__class__ == SearchMonitor:
2234            _self = None
2235        else:
2236            _self = self
2237        _pywrapcp.SearchMonitor_swiginit(self, _pywrapcp.new_SearchMonitor(_self, s))
thisown

The membership flag

def EnterSearch(self):
2240    def EnterSearch(self):
2241        r""" Beginning of the search."""
2242        return _pywrapcp.SearchMonitor_EnterSearch(self)

Beginning of the search.

def RestartSearch(self):
2244    def RestartSearch(self):
2245        r""" Restart the search."""
2246        return _pywrapcp.SearchMonitor_RestartSearch(self)

Restart the search.

def ExitSearch(self):
2248    def ExitSearch(self):
2249        r""" End of the search."""
2250        return _pywrapcp.SearchMonitor_ExitSearch(self)

End of the search.

def BeginNextDecision(self, b):
2252    def BeginNextDecision(self, b):
2253        r""" Before calling DecisionBuilder::Next."""
2254        return _pywrapcp.SearchMonitor_BeginNextDecision(self, b)

Before calling DecisionBuilder::Next.

def EndNextDecision(self, b, d):
2256    def EndNextDecision(self, b, d):
2257        r""" After calling DecisionBuilder::Next, along with the returned decision."""
2258        return _pywrapcp.SearchMonitor_EndNextDecision(self, b, d)

After calling DecisionBuilder::Next, along with the returned decision.

def ApplyDecision(self, d):
2260    def ApplyDecision(self, d):
2261        r""" Before applying the decision."""
2262        return _pywrapcp.SearchMonitor_ApplyDecision(self, d)

Before applying the decision.

def RefuteDecision(self, d):
2264    def RefuteDecision(self, d):
2265        r""" Before refuting the decision."""
2266        return _pywrapcp.SearchMonitor_RefuteDecision(self, d)

Before refuting the decision.

def AfterDecision(self, d, apply):
2268    def AfterDecision(self, d, apply):
2269        r"""
2270        Just after refuting or applying the decision, apply is true after Apply.
2271        This is called only if the Apply() or Refute() methods have not failed.
2272        """
2273        return _pywrapcp.SearchMonitor_AfterDecision(self, d, apply)

Just after refuting or applying the decision, apply is true after Apply. This is called only if the Apply() or Refute() methods have not failed.

def BeginFail(self):
2275    def BeginFail(self):
2276        r""" Just when the failure occurs."""
2277        return _pywrapcp.SearchMonitor_BeginFail(self)

Just when the failure occurs.

def EndFail(self):
2279    def EndFail(self):
2280        r""" After completing the backtrack."""
2281        return _pywrapcp.SearchMonitor_EndFail(self)

After completing the backtrack.

def BeginInitialPropagation(self):
2283    def BeginInitialPropagation(self):
2284        r""" Before the initial propagation."""
2285        return _pywrapcp.SearchMonitor_BeginInitialPropagation(self)

Before the initial propagation.

def EndInitialPropagation(self):
2287    def EndInitialPropagation(self):
2288        r""" After the initial propagation."""
2289        return _pywrapcp.SearchMonitor_EndInitialPropagation(self)

After the initial propagation.

def AcceptSolution(self):
2291    def AcceptSolution(self):
2292        r"""
2293        This method is called when a solution is found. It asserts whether the
2294        solution is valid. A value of false indicates that the solution
2295        should be discarded.
2296        """
2297        return _pywrapcp.SearchMonitor_AcceptSolution(self)

This method is called when a solution is found. It asserts whether the solution is valid. A value of false indicates that the solution should be discarded.

def AtSolution(self):
2299    def AtSolution(self):
2300        r"""
2301        This method is called when a valid solution is found. If the
2302        return value is true, then search will resume after. If the result
2303        is false, then search will stop there.
2304        """
2305        return _pywrapcp.SearchMonitor_AtSolution(self)

This method is called when a valid solution is found. If the return value is true, then search will resume after. If the result is false, then search will stop there.

def NoMoreSolutions(self):
2307    def NoMoreSolutions(self):
2308        r""" When the search tree is finished."""
2309        return _pywrapcp.SearchMonitor_NoMoreSolutions(self)

When the search tree is finished.

def LocalOptimum(self):
2311    def LocalOptimum(self):
2312        r"""
2313        When a local optimum is reached. If 'true' is returned, the last solution
2314        is discarded and the search proceeds with the next one.
2315        """
2316        return _pywrapcp.SearchMonitor_LocalOptimum(self)

When a local optimum is reached. If 'true' is returned, the last solution is discarded and the search proceeds with the next one.

def AcceptDelta(self, delta, deltadelta):
2318    def AcceptDelta(self, delta, deltadelta):
2319        
2320        return _pywrapcp.SearchMonitor_AcceptDelta(self, delta, deltadelta)
def AcceptNeighbor(self):
2322    def AcceptNeighbor(self):
2323        r""" After accepting a neighbor during local search."""
2324        return _pywrapcp.SearchMonitor_AcceptNeighbor(self)

After accepting a neighbor during local search.

def solver(self):
2326    def solver(self):
2327        return _pywrapcp.SearchMonitor_solver(self)
Inherited Members
BaseObject
DebugString
class IntExpr(PropagationBaseObject):
2341class IntExpr(PropagationBaseObject):
2342    r"""
2343    The class IntExpr is the base of all integer expressions in
2344    constraint programming.
2345    It contains the basic protocol for an expression:
2346      - setting and modifying its bound
2347      - querying if it is bound
2348      - listening to events modifying its bounds
2349      - casting it into a variable (instance of IntVar)
2350    """
2351
2352    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2353
2354    def __init__(self, *args, **kwargs):
2355        raise AttributeError("No constructor defined - class is abstract")
2356
2357    def Min(self):
2358        return _pywrapcp.IntExpr_Min(self)
2359
2360    def SetMin(self, m):
2361        return _pywrapcp.IntExpr_SetMin(self, m)
2362
2363    def Max(self):
2364        return _pywrapcp.IntExpr_Max(self)
2365
2366    def SetMax(self, m):
2367        return _pywrapcp.IntExpr_SetMax(self, m)
2368
2369    def SetRange(self, l, u):
2370        r""" This method sets both the min and the max of the expression."""
2371        return _pywrapcp.IntExpr_SetRange(self, l, u)
2372
2373    def SetValue(self, v):
2374        r""" This method sets the value of the expression."""
2375        return _pywrapcp.IntExpr_SetValue(self, v)
2376
2377    def Bound(self):
2378        r""" Returns true if the min and the max of the expression are equal."""
2379        return _pywrapcp.IntExpr_Bound(self)
2380
2381    def IsVar(self):
2382        r""" Returns true if the expression is indeed a variable."""
2383        return _pywrapcp.IntExpr_IsVar(self)
2384
2385    def Var(self):
2386        r""" Creates a variable from the expression."""
2387        return _pywrapcp.IntExpr_Var(self)
2388
2389    def VarWithName(self, name):
2390        r"""
2391        Creates a variable from the expression and set the name of the
2392        resulting var. If the expression is already a variable, then it
2393        will set the name of the expression, possibly overwriting it.
2394        This is just a shortcut to Var() followed by set_name().
2395        """
2396        return _pywrapcp.IntExpr_VarWithName(self, name)
2397
2398    def WhenRange(self, *args):
2399        r"""
2400        *Overload 1:*
2401        Attach a demon that will watch the min or the max of the expression.
2402
2403        |
2404
2405        *Overload 2:*
2406        Attach a demon that will watch the min or the max of the expression.
2407        """
2408        return _pywrapcp.IntExpr_WhenRange(self, *args)
2409
2410    def __repr__(self):
2411        return _pywrapcp.IntExpr___repr__(self)
2412
2413    def __str__(self):
2414        return _pywrapcp.IntExpr___str__(self)
2415
2416    def __add__(self, *args):
2417        return _pywrapcp.IntExpr___add__(self, *args)
2418
2419    def __radd__(self, v):
2420        return _pywrapcp.IntExpr___radd__(self, v)
2421
2422    def __sub__(self, *args):
2423        return _pywrapcp.IntExpr___sub__(self, *args)
2424
2425    def __rsub__(self, v):
2426        return _pywrapcp.IntExpr___rsub__(self, v)
2427
2428    def __mul__(self, *args):
2429        return _pywrapcp.IntExpr___mul__(self, *args)
2430
2431    def __rmul__(self, v):
2432        return _pywrapcp.IntExpr___rmul__(self, v)
2433
2434    def __floordiv__(self, *args):
2435        return _pywrapcp.IntExpr___floordiv__(self, *args)
2436
2437    def __mod__(self, *args):
2438        return _pywrapcp.IntExpr___mod__(self, *args)
2439
2440    def __neg__(self):
2441        return _pywrapcp.IntExpr___neg__(self)
2442
2443    def __abs__(self):
2444        return _pywrapcp.IntExpr___abs__(self)
2445
2446    def Square(self):
2447        return _pywrapcp.IntExpr_Square(self)
2448
2449    def __eq__(self, *args):
2450        return _pywrapcp.IntExpr___eq__(self, *args)
2451
2452    def __ne__(self, *args):
2453        return _pywrapcp.IntExpr___ne__(self, *args)
2454
2455    def __ge__(self, *args):
2456        return _pywrapcp.IntExpr___ge__(self, *args)
2457
2458    def __gt__(self, *args):
2459        return _pywrapcp.IntExpr___gt__(self, *args)
2460
2461    def __le__(self, *args):
2462        return _pywrapcp.IntExpr___le__(self, *args)
2463
2464    def __lt__(self, *args):
2465        return _pywrapcp.IntExpr___lt__(self, *args)
2466
2467    def MapTo(self, vars):
2468        return _pywrapcp.IntExpr_MapTo(self, vars)
2469
2470    def IndexOf(self, *args):
2471        return _pywrapcp.IntExpr_IndexOf(self, *args)
2472
2473    def IsMember(self, values):
2474        return _pywrapcp.IntExpr_IsMember(self, values)
2475
2476    def Member(self, values):
2477        return _pywrapcp.IntExpr_Member(self, values)
2478
2479    def NotMember(self, starts, ends):
2480        return _pywrapcp.IntExpr_NotMember(self, starts, ends)

The class IntExpr is the base of all integer expressions in constraint programming.

It contains the basic protocol for an expression:
  • setting and modifying its bound
  • querying if it is bound
  • listening to events modifying its bounds
  • casting it into a variable (instance of IntVar)
IntExpr(*args, **kwargs)
2354    def __init__(self, *args, **kwargs):
2355        raise AttributeError("No constructor defined - class is abstract")
thisown

The membership flag

def Min(self):
2357    def Min(self):
2358        return _pywrapcp.IntExpr_Min(self)
def SetMin(self, m):
2360    def SetMin(self, m):
2361        return _pywrapcp.IntExpr_SetMin(self, m)
def Max(self):
2363    def Max(self):
2364        return _pywrapcp.IntExpr_Max(self)
def SetMax(self, m):
2366    def SetMax(self, m):
2367        return _pywrapcp.IntExpr_SetMax(self, m)
def SetRange(self, l, u):
2369    def SetRange(self, l, u):
2370        r""" This method sets both the min and the max of the expression."""
2371        return _pywrapcp.IntExpr_SetRange(self, l, u)

This method sets both the min and the max of the expression.

def SetValue(self, v):
2373    def SetValue(self, v):
2374        r""" This method sets the value of the expression."""
2375        return _pywrapcp.IntExpr_SetValue(self, v)

This method sets the value of the expression.

def Bound(self):
2377    def Bound(self):
2378        r""" Returns true if the min and the max of the expression are equal."""
2379        return _pywrapcp.IntExpr_Bound(self)

Returns true if the min and the max of the expression are equal.

def IsVar(self):
2381    def IsVar(self):
2382        r""" Returns true if the expression is indeed a variable."""
2383        return _pywrapcp.IntExpr_IsVar(self)

Returns true if the expression is indeed a variable.

def Var(self):
2385    def Var(self):
2386        r""" Creates a variable from the expression."""
2387        return _pywrapcp.IntExpr_Var(self)

Creates a variable from the expression.

def VarWithName(self, name):
2389    def VarWithName(self, name):
2390        r"""
2391        Creates a variable from the expression and set the name of the
2392        resulting var. If the expression is already a variable, then it
2393        will set the name of the expression, possibly overwriting it.
2394        This is just a shortcut to Var() followed by set_name().
2395        """
2396        return _pywrapcp.IntExpr_VarWithName(self, name)

Creates a variable from the expression and set the name of the resulting var. If the expression is already a variable, then it will set the name of the expression, possibly overwriting it. This is just a shortcut to Var() followed by set_name().

def WhenRange(self, *args):
2398    def WhenRange(self, *args):
2399        r"""
2400        *Overload 1:*
2401        Attach a demon that will watch the min or the max of the expression.
2402
2403        |
2404
2405        *Overload 2:*
2406        Attach a demon that will watch the min or the max of the expression.
2407        """
2408        return _pywrapcp.IntExpr_WhenRange(self, *args)

Overload 1: Attach a demon that will watch the min or the max of the expression.

|

Overload 2: Attach a demon that will watch the min or the max of the expression.

def Square(self):
2446    def Square(self):
2447        return _pywrapcp.IntExpr_Square(self)
def MapTo(self, vars):
2467    def MapTo(self, vars):
2468        return _pywrapcp.IntExpr_MapTo(self, vars)
def IndexOf(self, *args):
2470    def IndexOf(self, *args):
2471        return _pywrapcp.IntExpr_IndexOf(self, *args)
def IsMember(self, values):
2473    def IsMember(self, values):
2474        return _pywrapcp.IntExpr_IsMember(self, values)
def Member(self, values):
2476    def Member(self, values):
2477        return _pywrapcp.IntExpr_Member(self, values)
def NotMember(self, starts, ends):
2479    def NotMember(self, starts, ends):
2480        return _pywrapcp.IntExpr_NotMember(self, starts, ends)
class IntVarIterator(BaseObject):
2484class IntVarIterator(BaseObject):
2485    r"""
2486     The class Iterator has two direct subclasses. HoleIterators
2487     iterates over all holes, that is value removed between the
2488     current min and max of the variable since the last time the
2489     variable was processed in the queue. DomainIterators iterates
2490     over all elements of the variable domain. Both iterators are not
2491     robust to domain changes. Hole iterators can also report values outside
2492     the current min and max of the variable.
2493     HoleIterators should only be called from a demon attached to the
2494     variable that has created this iterator.
2495     IntVar* current_var;
2496     std::unique_ptr<IntVarIterator> it(current_var->MakeHoleIterator(false));
2497     for (const int64_t hole : InitAndGetValues(it)) {
2498    use the hole
2499     }
2500    """
2501
2502    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2503
2504    def __init__(self, *args, **kwargs):
2505        raise AttributeError("No constructor defined - class is abstract")
2506    __repr__ = _swig_repr
2507
2508    def Init(self):
2509        r""" This method must be called before each loop."""
2510        return _pywrapcp.IntVarIterator_Init(self)
2511
2512    def Ok(self):
2513        r""" This method indicates if we can call Value() or not."""
2514        return _pywrapcp.IntVarIterator_Ok(self)
2515
2516    def Value(self):
2517        r""" This method returns the current value of the iterator."""
2518        return _pywrapcp.IntVarIterator_Value(self)
2519
2520    def Next(self):
2521        r""" This method moves the iterator to the next value."""
2522        return _pywrapcp.IntVarIterator_Next(self)
2523
2524    def DebugString(self):
2525        r""" Pretty Print."""
2526        return _pywrapcp.IntVarIterator_DebugString(self)
2527
2528    def __iter__(self):
2529      self.Init()
2530      return self
2531
2532    def next(self):
2533      if self.Ok():
2534        result = self.Value()
2535        self.Next()
2536        return result
2537      else:
2538        raise StopIteration()
2539
2540    def __next__(self):
2541      return self.next()

The class Iterator has two direct subclasses. HoleIterators iterates over all holes, that is value removed between the current min and max of the variable since the last time the variable was processed in the queue. DomainIterators iterates over all elements of the variable domain. Both iterators are not robust to domain changes. Hole iterators can also report values outside the current min and max of the variable. HoleIterators should only be called from a demon attached to the variable that has created this iterator. IntVar* current_var; std::unique_ptr it(current_var->MakeHoleIterator(false)); for (const int64_t hole : InitAndGetValues(it)) { use the hole }

IntVarIterator(*args, **kwargs)
2504    def __init__(self, *args, **kwargs):
2505        raise AttributeError("No constructor defined - class is abstract")
thisown

The membership flag

def Init(self):
2508    def Init(self):
2509        r""" This method must be called before each loop."""
2510        return _pywrapcp.IntVarIterator_Init(self)

This method must be called before each loop.

def Ok(self):
2512    def Ok(self):
2513        r""" This method indicates if we can call Value() or not."""
2514        return _pywrapcp.IntVarIterator_Ok(self)

This method indicates if we can call Value() or not.

def Value(self):
2516    def Value(self):
2517        r""" This method returns the current value of the iterator."""
2518        return _pywrapcp.IntVarIterator_Value(self)

This method returns the current value of the iterator.

def Next(self):
2520    def Next(self):
2521        r""" This method moves the iterator to the next value."""
2522        return _pywrapcp.IntVarIterator_Next(self)

This method moves the iterator to the next value.

def DebugString(self):
2524    def DebugString(self):
2525        r""" Pretty Print."""
2526        return _pywrapcp.IntVarIterator_DebugString(self)

Pretty Print.

def next(self):
2532    def next(self):
2533      if self.Ok():
2534        result = self.Value()
2535        self.Next()
2536        return result
2537      else:
2538        raise StopIteration()
class IntVar(IntExpr):
2546class IntVar(IntExpr):
2547    r"""
2548    The class IntVar is a subset of IntExpr. In addition to the
2549    IntExpr protocol, it offers persistence, removing values from the domains,
2550    and a finer model for events.
2551    """
2552
2553    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2554
2555    def __init__(self, *args, **kwargs):
2556        raise AttributeError("No constructor defined - class is abstract")
2557
2558    def IsVar(self):
2559        return _pywrapcp.IntVar_IsVar(self)
2560
2561    def Var(self):
2562        return _pywrapcp.IntVar_Var(self)
2563
2564    def Value(self):
2565        r"""
2566        This method returns the value of the variable. This method checks
2567        before that the variable is bound.
2568        """
2569        return _pywrapcp.IntVar_Value(self)
2570
2571    def RemoveValue(self, v):
2572        r""" This method removes the value 'v' from the domain of the variable."""
2573        return _pywrapcp.IntVar_RemoveValue(self, v)
2574
2575    def RemoveInterval(self, l, u):
2576        r"""
2577        This method removes the interval 'l' .. 'u' from the domain of
2578        the variable. It assumes that 'l' <= 'u'.
2579        """
2580        return _pywrapcp.IntVar_RemoveInterval(self, l, u)
2581
2582    def RemoveValues(self, values):
2583        r""" This method remove the values from the domain of the variable."""
2584        return _pywrapcp.IntVar_RemoveValues(self, values)
2585
2586    def SetValues(self, values):
2587        r""" This method intersects the current domain with the values in the array."""
2588        return _pywrapcp.IntVar_SetValues(self, values)
2589
2590    def WhenBound(self, *args):
2591        r"""
2592        *Overload 1:*
2593        This method attaches a demon that will be awakened when the
2594        variable is bound.
2595
2596        |
2597
2598        *Overload 2:*
2599        This method attaches a closure that will be awakened when the
2600        variable is bound.
2601        """
2602        return _pywrapcp.IntVar_WhenBound(self, *args)
2603
2604    def WhenDomain(self, *args):
2605        r"""
2606        *Overload 1:*
2607        This method attaches a demon that will watch any domain
2608        modification of the domain of the variable.
2609
2610        |
2611
2612        *Overload 2:*
2613        This method attaches a closure that will watch any domain
2614        modification of the domain of the variable.
2615        """
2616        return _pywrapcp.IntVar_WhenDomain(self, *args)
2617
2618    def Size(self):
2619        r""" This method returns the number of values in the domain of the variable."""
2620        return _pywrapcp.IntVar_Size(self)
2621
2622    def Contains(self, v):
2623        r"""
2624        This method returns whether the value 'v' is in the domain of the
2625        variable.
2626        """
2627        return _pywrapcp.IntVar_Contains(self, v)
2628
2629    def HoleIteratorAux(self, reversible):
2630        r"""
2631        Creates a hole iterator. When 'reversible' is false, the returned
2632        object is created on the normal C++ heap and the solver does NOT
2633        take ownership of the object.
2634        """
2635        return _pywrapcp.IntVar_HoleIteratorAux(self, reversible)
2636
2637    def DomainIteratorAux(self, reversible):
2638        r"""
2639        Creates a domain iterator. When 'reversible' is false, the
2640        returned object is created on the normal C++ heap and the solver
2641        does NOT take ownership of the object.
2642        """
2643        return _pywrapcp.IntVar_DomainIteratorAux(self, reversible)
2644
2645    def OldMin(self):
2646        r""" Returns the previous min."""
2647        return _pywrapcp.IntVar_OldMin(self)
2648
2649    def OldMax(self):
2650        r""" Returns the previous max."""
2651        return _pywrapcp.IntVar_OldMax(self)
2652
2653    def __repr__(self):
2654        return _pywrapcp.IntVar___repr__(self)
2655
2656    def __str__(self):
2657        return _pywrapcp.IntVar___str__(self)
2658
2659    def DomainIterator(self):
2660      return iter(self.DomainIteratorAux(False))
2661
2662    def HoleIterator(self):
2663      return iter(self.HoleIteratorAux(False))

The class IntVar is a subset of IntExpr. In addition to the IntExpr protocol, it offers persistence, removing values from the domains, and a finer model for events.

IntVar(*args, **kwargs)
2555    def __init__(self, *args, **kwargs):
2556        raise AttributeError("No constructor defined - class is abstract")
thisown

The membership flag

def IsVar(self):
2558    def IsVar(self):
2559        return _pywrapcp.IntVar_IsVar(self)

Returns true if the expression is indeed a variable.

def Var(self):
2561    def Var(self):
2562        return _pywrapcp.IntVar_Var(self)

Creates a variable from the expression.

def Value(self):
2564    def Value(self):
2565        r"""
2566        This method returns the value of the variable. This method checks
2567        before that the variable is bound.
2568        """
2569        return _pywrapcp.IntVar_Value(self)

This method returns the value of the variable. This method checks before that the variable is bound.

def RemoveValue(self, v):
2571    def RemoveValue(self, v):
2572        r""" This method removes the value 'v' from the domain of the variable."""
2573        return _pywrapcp.IntVar_RemoveValue(self, v)

This method removes the value 'v' from the domain of the variable.

def RemoveInterval(self, l, u):
2575    def RemoveInterval(self, l, u):
2576        r"""
2577        This method removes the interval 'l' .. 'u' from the domain of
2578        the variable. It assumes that 'l' <= 'u'.
2579        """
2580        return _pywrapcp.IntVar_RemoveInterval(self, l, u)

This method removes the interval 'l' .. 'u' from the domain of the variable. It assumes that 'l' <= 'u'.

def RemoveValues(self, values):
2582    def RemoveValues(self, values):
2583        r""" This method remove the values from the domain of the variable."""
2584        return _pywrapcp.IntVar_RemoveValues(self, values)

This method remove the values from the domain of the variable.

def SetValues(self, values):
2586    def SetValues(self, values):
2587        r""" This method intersects the current domain with the values in the array."""
2588        return _pywrapcp.IntVar_SetValues(self, values)

This method intersects the current domain with the values in the array.

def WhenBound(self, *args):
2590    def WhenBound(self, *args):
2591        r"""
2592        *Overload 1:*
2593        This method attaches a demon that will be awakened when the
2594        variable is bound.
2595
2596        |
2597
2598        *Overload 2:*
2599        This method attaches a closure that will be awakened when the
2600        variable is bound.
2601        """
2602        return _pywrapcp.IntVar_WhenBound(self, *args)

Overload 1: This method attaches a demon that will be awakened when the variable is bound.

|

Overload 2: This method attaches a closure that will be awakened when the variable is bound.

def WhenDomain(self, *args):
2604    def WhenDomain(self, *args):
2605        r"""
2606        *Overload 1:*
2607        This method attaches a demon that will watch any domain
2608        modification of the domain of the variable.
2609
2610        |
2611
2612        *Overload 2:*
2613        This method attaches a closure that will watch any domain
2614        modification of the domain of the variable.
2615        """
2616        return _pywrapcp.IntVar_WhenDomain(self, *args)

Overload 1: This method attaches a demon that will watch any domain modification of the domain of the variable.

|

Overload 2: This method attaches a closure that will watch any domain modification of the domain of the variable.

def Size(self):
2618    def Size(self):
2619        r""" This method returns the number of values in the domain of the variable."""
2620        return _pywrapcp.IntVar_Size(self)

This method returns the number of values in the domain of the variable.

def Contains(self, v):
2622    def Contains(self, v):
2623        r"""
2624        This method returns whether the value 'v' is in the domain of the
2625        variable.
2626        """
2627        return _pywrapcp.IntVar_Contains(self, v)

This method returns whether the value 'v' is in the domain of the variable.

def HoleIteratorAux(self, reversible):
2629    def HoleIteratorAux(self, reversible):
2630        r"""
2631        Creates a hole iterator. When 'reversible' is false, the returned
2632        object is created on the normal C++ heap and the solver does NOT
2633        take ownership of the object.
2634        """
2635        return _pywrapcp.IntVar_HoleIteratorAux(self, reversible)

Creates a hole iterator. When 'reversible' is false, the returned object is created on the normal C++ heap and the solver does NOT take ownership of the object.

def DomainIteratorAux(self, reversible):
2637    def DomainIteratorAux(self, reversible):
2638        r"""
2639        Creates a domain iterator. When 'reversible' is false, the
2640        returned object is created on the normal C++ heap and the solver
2641        does NOT take ownership of the object.
2642        """
2643        return _pywrapcp.IntVar_DomainIteratorAux(self, reversible)

Creates a domain iterator. When 'reversible' is false, the returned object is created on the normal C++ heap and the solver does NOT take ownership of the object.

def OldMin(self):
2645    def OldMin(self):
2646        r""" Returns the previous min."""
2647        return _pywrapcp.IntVar_OldMin(self)

Returns the previous min.

def OldMax(self):
2649    def OldMax(self):
2650        r""" Returns the previous max."""
2651        return _pywrapcp.IntVar_OldMax(self)

Returns the previous max.

def DomainIterator(self):
2659    def DomainIterator(self):
2660      return iter(self.DomainIteratorAux(False))
def HoleIterator(self):
2662    def HoleIterator(self):
2663      return iter(self.HoleIteratorAux(False))
class SolutionCollector(SearchMonitor):
2668class SolutionCollector(SearchMonitor):
2669    r"""
2670    This class is the root class of all solution collectors.
2671    It implements a basic query API to be used independently
2672    of the collector used.
2673    """
2674
2675    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2676
2677    def __init__(self, *args, **kwargs):
2678        raise AttributeError("No constructor defined")
2679    __repr__ = _swig_repr
2680
2681    def DebugString(self):
2682        return _pywrapcp.SolutionCollector_DebugString(self)
2683
2684    def Add(self, *args):
2685        return _pywrapcp.SolutionCollector_Add(self, *args)
2686
2687    def AddObjective(self, objective):
2688        return _pywrapcp.SolutionCollector_AddObjective(self, objective)
2689
2690    def EnterSearch(self):
2691        r""" Beginning of the search."""
2692        return _pywrapcp.SolutionCollector_EnterSearch(self)
2693
2694    def SolutionCount(self):
2695        r""" Returns how many solutions were stored during the search."""
2696        return _pywrapcp.SolutionCollector_SolutionCount(self)
2697
2698    def Solution(self, n):
2699        r""" Returns the nth solution."""
2700        return _pywrapcp.SolutionCollector_Solution(self, n)
2701
2702    def WallTime(self, n):
2703        r""" Returns the wall time in ms for the nth solution."""
2704        return _pywrapcp.SolutionCollector_WallTime(self, n)
2705
2706    def Branches(self, n):
2707        r""" Returns the number of branches when the nth solution was found."""
2708        return _pywrapcp.SolutionCollector_Branches(self, n)
2709
2710    def Failures(self, n):
2711        r"""
2712        Returns the number of failures encountered at the time of the nth
2713        solution.
2714        """
2715        return _pywrapcp.SolutionCollector_Failures(self, n)
2716
2717    def ObjectiveValue(self, n):
2718        r""" Returns the objective value of the nth solution."""
2719        return _pywrapcp.SolutionCollector_ObjectiveValue(self, n)
2720
2721    def Value(self, n, var):
2722        r""" This is a shortcut to get the Value of 'var' in the nth solution."""
2723        return _pywrapcp.SolutionCollector_Value(self, n, var)
2724
2725    def StartValue(self, n, var):
2726        r""" This is a shortcut to get the StartValue of 'var' in the nth solution."""
2727        return _pywrapcp.SolutionCollector_StartValue(self, n, var)
2728
2729    def EndValue(self, n, var):
2730        r""" This is a shortcut to get the EndValue of 'var' in the nth solution."""
2731        return _pywrapcp.SolutionCollector_EndValue(self, n, var)
2732
2733    def DurationValue(self, n, var):
2734        r""" This is a shortcut to get the DurationValue of 'var' in the nth solution."""
2735        return _pywrapcp.SolutionCollector_DurationValue(self, n, var)
2736
2737    def PerformedValue(self, n, var):
2738        r""" This is a shortcut to get the PerformedValue of 'var' in the nth solution."""
2739        return _pywrapcp.SolutionCollector_PerformedValue(self, n, var)
2740
2741    def ForwardSequence(self, n, var):
2742        r"""
2743        This is a shortcut to get the ForwardSequence of 'var' in the
2744        nth solution. The forward sequence is the list of ranked interval
2745        variables starting from the start of the sequence.
2746        """
2747        return _pywrapcp.SolutionCollector_ForwardSequence(self, n, var)
2748
2749    def BackwardSequence(self, n, var):
2750        r"""
2751        This is a shortcut to get the BackwardSequence of 'var' in the
2752        nth solution. The backward sequence is the list of ranked interval
2753        variables starting from the end of the sequence.
2754        """
2755        return _pywrapcp.SolutionCollector_BackwardSequence(self, n, var)
2756
2757    def Unperformed(self, n, var):
2758        r"""
2759        This is a shortcut to get the list of unperformed of 'var' in the
2760        nth solution.
2761        """
2762        return _pywrapcp.SolutionCollector_Unperformed(self, n, var)

This class is the root class of all solution collectors. It implements a basic query API to be used independently of the collector used.

SolutionCollector(*args, **kwargs)
2677    def __init__(self, *args, **kwargs):
2678        raise AttributeError("No constructor defined")
thisown

The membership flag

def DebugString(self):
2681    def DebugString(self):
2682        return _pywrapcp.SolutionCollector_DebugString(self)
def Add(self, *args):
2684    def Add(self, *args):
2685        return _pywrapcp.SolutionCollector_Add(self, *args)
def AddObjective(self, objective):
2687    def AddObjective(self, objective):
2688        return _pywrapcp.SolutionCollector_AddObjective(self, objective)
def EnterSearch(self):
2690    def EnterSearch(self):
2691        r""" Beginning of the search."""
2692        return _pywrapcp.SolutionCollector_EnterSearch(self)

Beginning of the search.

def SolutionCount(self):
2694    def SolutionCount(self):
2695        r""" Returns how many solutions were stored during the search."""
2696        return _pywrapcp.SolutionCollector_SolutionCount(self)

Returns how many solutions were stored during the search.

def Solution(self, n):
2698    def Solution(self, n):
2699        r""" Returns the nth solution."""
2700        return _pywrapcp.SolutionCollector_Solution(self, n)

Returns the nth solution.

def WallTime(self, n):
2702    def WallTime(self, n):
2703        r""" Returns the wall time in ms for the nth solution."""
2704        return _pywrapcp.SolutionCollector_WallTime(self, n)

Returns the wall time in ms for the nth solution.

def Branches(self, n):
2706    def Branches(self, n):
2707        r""" Returns the number of branches when the nth solution was found."""
2708        return _pywrapcp.SolutionCollector_Branches(self, n)

Returns the number of branches when the nth solution was found.

def Failures(self, n):
2710    def Failures(self, n):
2711        r"""
2712        Returns the number of failures encountered at the time of the nth
2713        solution.
2714        """
2715        return _pywrapcp.SolutionCollector_Failures(self, n)

Returns the number of failures encountered at the time of the nth solution.

def ObjectiveValue(self, n):
2717    def ObjectiveValue(self, n):
2718        r""" Returns the objective value of the nth solution."""
2719        return _pywrapcp.SolutionCollector_ObjectiveValue(self, n)

Returns the objective value of the nth solution.

def Value(self, n, var):
2721    def Value(self, n, var):
2722        r""" This is a shortcut to get the Value of 'var' in the nth solution."""
2723        return _pywrapcp.SolutionCollector_Value(self, n, var)

This is a shortcut to get the Value of 'var' in the nth solution.

def StartValue(self, n, var):
2725    def StartValue(self, n, var):
2726        r""" This is a shortcut to get the StartValue of 'var' in the nth solution."""
2727        return _pywrapcp.SolutionCollector_StartValue(self, n, var)

This is a shortcut to get the StartValue of 'var' in the nth solution.

def EndValue(self, n, var):
2729    def EndValue(self, n, var):
2730        r""" This is a shortcut to get the EndValue of 'var' in the nth solution."""
2731        return _pywrapcp.SolutionCollector_EndValue(self, n, var)

This is a shortcut to get the EndValue of 'var' in the nth solution.

def DurationValue(self, n, var):
2733    def DurationValue(self, n, var):
2734        r""" This is a shortcut to get the DurationValue of 'var' in the nth solution."""
2735        return _pywrapcp.SolutionCollector_DurationValue(self, n, var)

This is a shortcut to get the DurationValue of 'var' in the nth solution.

def PerformedValue(self, n, var):
2737    def PerformedValue(self, n, var):
2738        r""" This is a shortcut to get the PerformedValue of 'var' in the nth solution."""
2739        return _pywrapcp.SolutionCollector_PerformedValue(self, n, var)

This is a shortcut to get the PerformedValue of 'var' in the nth solution.

def ForwardSequence(self, n, var):
2741    def ForwardSequence(self, n, var):
2742        r"""
2743        This is a shortcut to get the ForwardSequence of 'var' in the
2744        nth solution. The forward sequence is the list of ranked interval
2745        variables starting from the start of the sequence.
2746        """
2747        return _pywrapcp.SolutionCollector_ForwardSequence(self, n, var)

This is a shortcut to get the ForwardSequence of 'var' in the nth solution. The forward sequence is the list of ranked interval variables starting from the start of the sequence.

def BackwardSequence(self, n, var):
2749    def BackwardSequence(self, n, var):
2750        r"""
2751        This is a shortcut to get the BackwardSequence of 'var' in the
2752        nth solution. The backward sequence is the list of ranked interval
2753        variables starting from the end of the sequence.
2754        """
2755        return _pywrapcp.SolutionCollector_BackwardSequence(self, n, var)

This is a shortcut to get the BackwardSequence of 'var' in the nth solution. The backward sequence is the list of ranked interval variables starting from the end of the sequence.

def Unperformed(self, n, var):
2757    def Unperformed(self, n, var):
2758        r"""
2759        This is a shortcut to get the list of unperformed of 'var' in the
2760        nth solution.
2761        """
2762        return _pywrapcp.SolutionCollector_Unperformed(self, n, var)

This is a shortcut to get the list of unperformed of 'var' in the nth solution.

class OptimizeVar(SearchMonitor):
2766class OptimizeVar(SearchMonitor):
2767    r"""
2768    This class encapsulates an objective. It requires the direction
2769    (minimize or maximize), the variable to optimize, and the
2770    improvement step.
2771    """
2772
2773    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2774
2775    def __init__(self, *args, **kwargs):
2776        raise AttributeError("No constructor defined")
2777    __repr__ = _swig_repr
2778
2779    def Best(self):
2780        r""" Returns the best value found during search."""
2781        return _pywrapcp.OptimizeVar_Best(self)
2782
2783    def Var(self):
2784        r""" Returns the variable that is optimized."""
2785        return _pywrapcp.OptimizeVar_Var(self)
2786
2787    def AcceptDelta(self, delta, deltadelta):
2788        r""" Internal methods."""
2789        return _pywrapcp.OptimizeVar_AcceptDelta(self, delta, deltadelta)
2790
2791    def EnterSearch(self):
2792        return _pywrapcp.OptimizeVar_EnterSearch(self)
2793
2794    def BeginNextDecision(self, db):
2795        return _pywrapcp.OptimizeVar_BeginNextDecision(self, db)
2796
2797    def RefuteDecision(self, d):
2798        return _pywrapcp.OptimizeVar_RefuteDecision(self, d)
2799
2800    def AtSolution(self):
2801        return _pywrapcp.OptimizeVar_AtSolution(self)
2802
2803    def AcceptSolution(self):
2804        return _pywrapcp.OptimizeVar_AcceptSolution(self)
2805
2806    def DebugString(self):
2807        return _pywrapcp.OptimizeVar_DebugString(self)

This class encapsulates an objective. It requires the direction (minimize or maximize), the variable to optimize, and the improvement step.

OptimizeVar(*args, **kwargs)
2775    def __init__(self, *args, **kwargs):
2776        raise AttributeError("No constructor defined")
thisown

The membership flag

def Best(self):
2779    def Best(self):
2780        r""" Returns the best value found during search."""
2781        return _pywrapcp.OptimizeVar_Best(self)

Returns the best value found during search.

def Var(self):
2783    def Var(self):
2784        r""" Returns the variable that is optimized."""
2785        return _pywrapcp.OptimizeVar_Var(self)

Returns the variable that is optimized.

def AcceptDelta(self, delta, deltadelta):
2787    def AcceptDelta(self, delta, deltadelta):
2788        r""" Internal methods."""
2789        return _pywrapcp.OptimizeVar_AcceptDelta(self, delta, deltadelta)

Internal methods.

def EnterSearch(self):
2791    def EnterSearch(self):
2792        return _pywrapcp.OptimizeVar_EnterSearch(self)

Beginning of the search.

def BeginNextDecision(self, db):
2794    def BeginNextDecision(self, db):
2795        return _pywrapcp.OptimizeVar_BeginNextDecision(self, db)

Before calling DecisionBuilder::Next.

def RefuteDecision(self, d):
2797    def RefuteDecision(self, d):
2798        return _pywrapcp.OptimizeVar_RefuteDecision(self, d)

Before refuting the decision.

def AtSolution(self):
2800    def AtSolution(self):
2801        return _pywrapcp.OptimizeVar_AtSolution(self)

This method is called when a valid solution is found. If the return value is true, then search will resume after. If the result is false, then search will stop there.

def AcceptSolution(self):
2803    def AcceptSolution(self):
2804        return _pywrapcp.OptimizeVar_AcceptSolution(self)

This method is called when a solution is found. It asserts whether the solution is valid. A value of false indicates that the solution should be discarded.

def DebugString(self):
2806    def DebugString(self):
2807        return _pywrapcp.OptimizeVar_DebugString(self)
class SearchLimit(SearchMonitor):
2811class SearchLimit(SearchMonitor):
2812    r""" Base class of all search limits."""
2813
2814    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2815
2816    def __init__(self, *args, **kwargs):
2817        raise AttributeError("No constructor defined - class is abstract")
2818    __repr__ = _swig_repr
2819    __swig_destroy__ = _pywrapcp.delete_SearchLimit
2820
2821    def Crossed(self):
2822        r""" Returns true if the limit has been crossed."""
2823        return _pywrapcp.SearchLimit_Crossed(self)
2824
2825    def Check(self):
2826        r"""
2827        This method is called to check the status of the limit. A return
2828        value of true indicates that we have indeed crossed the limit. In
2829        that case, this method will not be called again and the remaining
2830        search will be discarded.
2831        """
2832        return _pywrapcp.SearchLimit_Check(self)
2833
2834    def Init(self):
2835        r""" This method is called when the search limit is initialized."""
2836        return _pywrapcp.SearchLimit_Init(self)
2837
2838    def EnterSearch(self):
2839        r""" Internal methods."""
2840        return _pywrapcp.SearchLimit_EnterSearch(self)
2841
2842    def BeginNextDecision(self, b):
2843        return _pywrapcp.SearchLimit_BeginNextDecision(self, b)
2844
2845    def RefuteDecision(self, d):
2846        return _pywrapcp.SearchLimit_RefuteDecision(self, d)
2847
2848    def DebugString(self):
2849        return _pywrapcp.SearchLimit_DebugString(self)

Base class of all search limits.

SearchLimit(*args, **kwargs)
2816    def __init__(self, *args, **kwargs):
2817        raise AttributeError("No constructor defined - class is abstract")
thisown

The membership flag

def Crossed(self):
2821    def Crossed(self):
2822        r""" Returns true if the limit has been crossed."""
2823        return _pywrapcp.SearchLimit_Crossed(self)

Returns true if the limit has been crossed.

def Check(self):
2825    def Check(self):
2826        r"""
2827        This method is called to check the status of the limit. A return
2828        value of true indicates that we have indeed crossed the limit. In
2829        that case, this method will not be called again and the remaining
2830        search will be discarded.
2831        """
2832        return _pywrapcp.SearchLimit_Check(self)

This method is called to check the status of the limit. A return value of true indicates that we have indeed crossed the limit. In that case, this method will not be called again and the remaining search will be discarded.

def Init(self):
2834    def Init(self):
2835        r""" This method is called when the search limit is initialized."""
2836        return _pywrapcp.SearchLimit_Init(self)

This method is called when the search limit is initialized.

def EnterSearch(self):
2838    def EnterSearch(self):
2839        r""" Internal methods."""
2840        return _pywrapcp.SearchLimit_EnterSearch(self)

Internal methods.

def BeginNextDecision(self, b):
2842    def BeginNextDecision(self, b):
2843        return _pywrapcp.SearchLimit_BeginNextDecision(self, b)

Before calling DecisionBuilder::Next.

def RefuteDecision(self, d):
2845    def RefuteDecision(self, d):
2846        return _pywrapcp.SearchLimit_RefuteDecision(self, d)

Before refuting the decision.

def DebugString(self):
2848    def DebugString(self):
2849        return _pywrapcp.SearchLimit_DebugString(self)
class IntervalVar(PropagationBaseObject):
2853class IntervalVar(PropagationBaseObject):
2854    r"""
2855    Interval variables are often used in scheduling. The main characteristics
2856    of an IntervalVar are the start position, duration, and end
2857    date. All these characteristics can be queried and set, and demons can
2858    be posted on their modifications.
2859
2860    An important aspect is optionality: an IntervalVar can be performed or not.
2861    If unperformed, then it simply does not exist, and its characteristics
2862    cannot be accessed any more. An interval var is automatically marked
2863    as unperformed when it is not consistent anymore (start greater
2864    than end, duration < 0...)
2865    """
2866
2867    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2868
2869    def __init__(self, *args, **kwargs):
2870        raise AttributeError("No constructor defined - class is abstract")
2871
2872    def StartMin(self):
2873        r"""
2874        These methods query, set, and watch the start position of the
2875        interval var.
2876        """
2877        return _pywrapcp.IntervalVar_StartMin(self)
2878
2879    def StartMax(self):
2880        return _pywrapcp.IntervalVar_StartMax(self)
2881
2882    def SetStartMin(self, m):
2883        return _pywrapcp.IntervalVar_SetStartMin(self, m)
2884
2885    def SetStartMax(self, m):
2886        return _pywrapcp.IntervalVar_SetStartMax(self, m)
2887
2888    def SetStartRange(self, mi, ma):
2889        return _pywrapcp.IntervalVar_SetStartRange(self, mi, ma)
2890
2891    def OldStartMin(self):
2892        return _pywrapcp.IntervalVar_OldStartMin(self)
2893
2894    def OldStartMax(self):
2895        return _pywrapcp.IntervalVar_OldStartMax(self)
2896
2897    def WhenStartRange(self, *args):
2898        return _pywrapcp.IntervalVar_WhenStartRange(self, *args)
2899
2900    def WhenStartBound(self, *args):
2901        return _pywrapcp.IntervalVar_WhenStartBound(self, *args)
2902
2903    def DurationMin(self):
2904        r""" These methods query, set, and watch the duration of the interval var."""
2905        return _pywrapcp.IntervalVar_DurationMin(self)
2906
2907    def DurationMax(self):
2908        return _pywrapcp.IntervalVar_DurationMax(self)
2909
2910    def SetDurationMin(self, m):
2911        return _pywrapcp.IntervalVar_SetDurationMin(self, m)
2912
2913    def SetDurationMax(self, m):
2914        return _pywrapcp.IntervalVar_SetDurationMax(self, m)
2915
2916    def SetDurationRange(self, mi, ma):
2917        return _pywrapcp.IntervalVar_SetDurationRange(self, mi, ma)
2918
2919    def OldDurationMin(self):
2920        return _pywrapcp.IntervalVar_OldDurationMin(self)
2921
2922    def OldDurationMax(self):
2923        return _pywrapcp.IntervalVar_OldDurationMax(self)
2924
2925    def WhenDurationRange(self, *args):
2926        return _pywrapcp.IntervalVar_WhenDurationRange(self, *args)
2927
2928    def WhenDurationBound(self, *args):
2929        return _pywrapcp.IntervalVar_WhenDurationBound(self, *args)
2930
2931    def EndMin(self):
2932        r""" These methods query, set, and watch the end position of the interval var."""
2933        return _pywrapcp.IntervalVar_EndMin(self)
2934
2935    def EndMax(self):
2936        return _pywrapcp.IntervalVar_EndMax(self)
2937
2938    def SetEndMin(self, m):
2939        return _pywrapcp.IntervalVar_SetEndMin(self, m)
2940
2941    def SetEndMax(self, m):
2942        return _pywrapcp.IntervalVar_SetEndMax(self, m)
2943
2944    def SetEndRange(self, mi, ma):
2945        return _pywrapcp.IntervalVar_SetEndRange(self, mi, ma)
2946
2947    def OldEndMin(self):
2948        return _pywrapcp.IntervalVar_OldEndMin(self)
2949
2950    def OldEndMax(self):
2951        return _pywrapcp.IntervalVar_OldEndMax(self)
2952
2953    def WhenEndRange(self, *args):
2954        return _pywrapcp.IntervalVar_WhenEndRange(self, *args)
2955
2956    def WhenEndBound(self, *args):
2957        return _pywrapcp.IntervalVar_WhenEndBound(self, *args)
2958
2959    def MustBePerformed(self):
2960        r"""
2961        These methods query, set, and watch the performed status of the
2962        interval var.
2963        """
2964        return _pywrapcp.IntervalVar_MustBePerformed(self)
2965
2966    def MayBePerformed(self):
2967        return _pywrapcp.IntervalVar_MayBePerformed(self)
2968
2969    def CannotBePerformed(self):
2970        return _pywrapcp.IntervalVar_CannotBePerformed(self)
2971
2972    def IsPerformedBound(self):
2973        return _pywrapcp.IntervalVar_IsPerformedBound(self)
2974
2975    def SetPerformed(self, val):
2976        return _pywrapcp.IntervalVar_SetPerformed(self, val)
2977
2978    def WasPerformedBound(self):
2979        return _pywrapcp.IntervalVar_WasPerformedBound(self)
2980
2981    def WhenPerformedBound(self, *args):
2982        return _pywrapcp.IntervalVar_WhenPerformedBound(self, *args)
2983
2984    def WhenAnything(self, *args):
2985        r"""
2986        *Overload 1:*
2987        Attaches a demon awakened when anything about this interval changes.
2988
2989        |
2990
2991        *Overload 2:*
2992        Attaches a closure awakened when anything about this interval changes.
2993        """
2994        return _pywrapcp.IntervalVar_WhenAnything(self, *args)
2995
2996    def StartExpr(self):
2997        r"""
2998        These methods create expressions encapsulating the start, end
2999        and duration of the interval var. Please note that these must not
3000        be used if the interval var is unperformed.
3001        """
3002        return _pywrapcp.IntervalVar_StartExpr(self)
3003
3004    def DurationExpr(self):
3005        return _pywrapcp.IntervalVar_DurationExpr(self)
3006
3007    def EndExpr(self):
3008        return _pywrapcp.IntervalVar_EndExpr(self)
3009
3010    def PerformedExpr(self):
3011        return _pywrapcp.IntervalVar_PerformedExpr(self)
3012
3013    def SafeStartExpr(self, unperformed_value):
3014        r"""
3015        These methods create expressions encapsulating the start, end
3016        and duration of the interval var. If the interval var is
3017        unperformed, they will return the unperformed_value.
3018        """
3019        return _pywrapcp.IntervalVar_SafeStartExpr(self, unperformed_value)
3020
3021    def SafeDurationExpr(self, unperformed_value):
3022        return _pywrapcp.IntervalVar_SafeDurationExpr(self, unperformed_value)
3023
3024    def SafeEndExpr(self, unperformed_value):
3025        return _pywrapcp.IntervalVar_SafeEndExpr(self, unperformed_value)
3026
3027    def EndsAfterEnd(self, other):
3028        return _pywrapcp.IntervalVar_EndsAfterEnd(self, other)
3029
3030    def EndsAfterEndWithDelay(self, other, delay):
3031        return _pywrapcp.IntervalVar_EndsAfterEndWithDelay(self, other, delay)
3032
3033    def EndsAfterStart(self, other):
3034        return _pywrapcp.IntervalVar_EndsAfterStart(self, other)
3035
3036    def EndsAfterStartWithDelay(self, other, delay):
3037        return _pywrapcp.IntervalVar_EndsAfterStartWithDelay(self, other, delay)
3038
3039    def EndsAtEnd(self, other):
3040        return _pywrapcp.IntervalVar_EndsAtEnd(self, other)
3041
3042    def EndsAtEndWithDelay(self, other, delay):
3043        return _pywrapcp.IntervalVar_EndsAtEndWithDelay(self, other, delay)
3044
3045    def EndsAtStart(self, other):
3046        return _pywrapcp.IntervalVar_EndsAtStart(self, other)
3047
3048    def EndsAtStartWithDelay(self, other, delay):
3049        return _pywrapcp.IntervalVar_EndsAtStartWithDelay(self, other, delay)
3050
3051    def StartsAfterEnd(self, other):
3052        return _pywrapcp.IntervalVar_StartsAfterEnd(self, other)
3053
3054    def StartsAfterEndWithDelay(self, other, delay):
3055        return _pywrapcp.IntervalVar_StartsAfterEndWithDelay(self, other, delay)
3056
3057    def StartsAfterStart(self, other):
3058        return _pywrapcp.IntervalVar_StartsAfterStart(self, other)
3059
3060    def StartsAfterStartWithDelay(self, other, delay):
3061        return _pywrapcp.IntervalVar_StartsAfterStartWithDelay(self, other, delay)
3062
3063    def StartsAtEnd(self, other):
3064        return _pywrapcp.IntervalVar_StartsAtEnd(self, other)
3065
3066    def StartsAtEndWithDelay(self, other, delay):
3067        return _pywrapcp.IntervalVar_StartsAtEndWithDelay(self, other, delay)
3068
3069    def StartsAtStart(self, other):
3070        return _pywrapcp.IntervalVar_StartsAtStart(self, other)
3071
3072    def StartsAtStartWithDelay(self, other, delay):
3073        return _pywrapcp.IntervalVar_StartsAtStartWithDelay(self, other, delay)
3074
3075    def StaysInSync(self, other):
3076        return _pywrapcp.IntervalVar_StaysInSync(self, other)
3077
3078    def StaysInSyncWithDelay(self, other, delay):
3079        return _pywrapcp.IntervalVar_StaysInSyncWithDelay(self, other, delay)
3080
3081    def EndsAfter(self, date):
3082        return _pywrapcp.IntervalVar_EndsAfter(self, date)
3083
3084    def EndsAt(self, date):
3085        return _pywrapcp.IntervalVar_EndsAt(self, date)
3086
3087    def EndsBefore(self, date):
3088        return _pywrapcp.IntervalVar_EndsBefore(self, date)
3089
3090    def StartsAfter(self, date):
3091        return _pywrapcp.IntervalVar_StartsAfter(self, date)
3092
3093    def StartsAt(self, date):
3094        return _pywrapcp.IntervalVar_StartsAt(self, date)
3095
3096    def StartsBefore(self, date):
3097        return _pywrapcp.IntervalVar_StartsBefore(self, date)
3098
3099    def CrossesDate(self, date):
3100        return _pywrapcp.IntervalVar_CrossesDate(self, date)
3101
3102    def AvoidsDate(self, date):
3103        return _pywrapcp.IntervalVar_AvoidsDate(self, date)
3104
3105    def __repr__(self):
3106        return _pywrapcp.IntervalVar___repr__(self)
3107
3108    def __str__(self):
3109        return _pywrapcp.IntervalVar___str__(self)

Interval variables are often used in scheduling. The main characteristics of an IntervalVar are the start position, duration, and end date. All these characteristics can be queried and set, and demons can be posted on their modifications.

An important aspect is optionality: an IntervalVar can be performed or not. If unperformed, then it simply does not exist, and its characteristics cannot be accessed any more. An interval var is automatically marked as unperformed when it is not consistent anymore (start greater than end, duration < 0...)

IntervalVar(*args, **kwargs)
2869    def __init__(self, *args, **kwargs):
2870        raise AttributeError("No constructor defined - class is abstract")
thisown

The membership flag

def StartMin(self):
2872    def StartMin(self):
2873        r"""
2874        These methods query, set, and watch the start position of the
2875        interval var.
2876        """
2877        return _pywrapcp.IntervalVar_StartMin(self)

These methods query, set, and watch the start position of the interval var.

def StartMax(self):
2879    def StartMax(self):
2880        return _pywrapcp.IntervalVar_StartMax(self)
def SetStartMin(self, m):
2882    def SetStartMin(self, m):
2883        return _pywrapcp.IntervalVar_SetStartMin(self, m)
def SetStartMax(self, m):
2885    def SetStartMax(self, m):
2886        return _pywrapcp.IntervalVar_SetStartMax(self, m)
def SetStartRange(self, mi, ma):
2888    def SetStartRange(self, mi, ma):
2889        return _pywrapcp.IntervalVar_SetStartRange(self, mi, ma)
def OldStartMin(self):
2891    def OldStartMin(self):
2892        return _pywrapcp.IntervalVar_OldStartMin(self)
def OldStartMax(self):
2894    def OldStartMax(self):
2895        return _pywrapcp.IntervalVar_OldStartMax(self)
def WhenStartRange(self, *args):
2897    def WhenStartRange(self, *args):
2898        return _pywrapcp.IntervalVar_WhenStartRange(self, *args)
def WhenStartBound(self, *args):
2900    def WhenStartBound(self, *args):
2901        return _pywrapcp.IntervalVar_WhenStartBound(self, *args)
def DurationMin(self):
2903    def DurationMin(self):
2904        r""" These methods query, set, and watch the duration of the interval var."""
2905        return _pywrapcp.IntervalVar_DurationMin(self)

These methods query, set, and watch the duration of the interval var.

def DurationMax(self):
2907    def DurationMax(self):
2908        return _pywrapcp.IntervalVar_DurationMax(self)
def SetDurationMin(self, m):
2910    def SetDurationMin(self, m):
2911        return _pywrapcp.IntervalVar_SetDurationMin(self, m)
def SetDurationMax(self, m):
2913    def SetDurationMax(self, m):
2914        return _pywrapcp.IntervalVar_SetDurationMax(self, m)
def SetDurationRange(self, mi, ma):
2916    def SetDurationRange(self, mi, ma):
2917        return _pywrapcp.IntervalVar_SetDurationRange(self, mi, ma)
def OldDurationMin(self):
2919    def OldDurationMin(self):
2920        return _pywrapcp.IntervalVar_OldDurationMin(self)
def OldDurationMax(self):
2922    def OldDurationMax(self):
2923        return _pywrapcp.IntervalVar_OldDurationMax(self)
def WhenDurationRange(self, *args):
2925    def WhenDurationRange(self, *args):
2926        return _pywrapcp.IntervalVar_WhenDurationRange(self, *args)
def WhenDurationBound(self, *args):
2928    def WhenDurationBound(self, *args):
2929        return _pywrapcp.IntervalVar_WhenDurationBound(self, *args)
def EndMin(self):
2931    def EndMin(self):
2932        r""" These methods query, set, and watch the end position of the interval var."""
2933        return _pywrapcp.IntervalVar_EndMin(self)

These methods query, set, and watch the end position of the interval var.

def EndMax(self):
2935    def EndMax(self):
2936        return _pywrapcp.IntervalVar_EndMax(self)
def SetEndMin(self, m):
2938    def SetEndMin(self, m):
2939        return _pywrapcp.IntervalVar_SetEndMin(self, m)
def SetEndMax(self, m):
2941    def SetEndMax(self, m):
2942        return _pywrapcp.IntervalVar_SetEndMax(self, m)
def SetEndRange(self, mi, ma):
2944    def SetEndRange(self, mi, ma):
2945        return _pywrapcp.IntervalVar_SetEndRange(self, mi, ma)
def OldEndMin(self):
2947    def OldEndMin(self):
2948        return _pywrapcp.IntervalVar_OldEndMin(self)
def OldEndMax(self):
2950    def OldEndMax(self):
2951        return _pywrapcp.IntervalVar_OldEndMax(self)
def WhenEndRange(self, *args):
2953    def WhenEndRange(self, *args):
2954        return _pywrapcp.IntervalVar_WhenEndRange(self, *args)
def WhenEndBound(self, *args):
2956    def WhenEndBound(self, *args):
2957        return _pywrapcp.IntervalVar_WhenEndBound(self, *args)
def MustBePerformed(self):
2959    def MustBePerformed(self):
2960        r"""
2961        These methods query, set, and watch the performed status of the
2962        interval var.
2963        """
2964        return _pywrapcp.IntervalVar_MustBePerformed(self)

These methods query, set, and watch the performed status of the interval var.

def MayBePerformed(self):
2966    def MayBePerformed(self):
2967        return _pywrapcp.IntervalVar_MayBePerformed(self)
def CannotBePerformed(self):
2969    def CannotBePerformed(self):
2970        return _pywrapcp.IntervalVar_CannotBePerformed(self)
def IsPerformedBound(self):
2972    def IsPerformedBound(self):
2973        return _pywrapcp.IntervalVar_IsPerformedBound(self)
def SetPerformed(self, val):
2975    def SetPerformed(self, val):
2976        return _pywrapcp.IntervalVar_SetPerformed(self, val)
def WasPerformedBound(self):
2978    def WasPerformedBound(self):
2979        return _pywrapcp.IntervalVar_WasPerformedBound(self)
def WhenPerformedBound(self, *args):
2981    def WhenPerformedBound(self, *args):
2982        return _pywrapcp.IntervalVar_WhenPerformedBound(self, *args)
def WhenAnything(self, *args):
2984    def WhenAnything(self, *args):
2985        r"""
2986        *Overload 1:*
2987        Attaches a demon awakened when anything about this interval changes.
2988
2989        |
2990
2991        *Overload 2:*
2992        Attaches a closure awakened when anything about this interval changes.
2993        """
2994        return _pywrapcp.IntervalVar_WhenAnything(self, *args)

Overload 1: Attaches a demon awakened when anything about this interval changes.

|

Overload 2: Attaches a closure awakened when anything about this interval changes.

def StartExpr(self):
2996    def StartExpr(self):
2997        r"""
2998        These methods create expressions encapsulating the start, end
2999        and duration of the interval var. Please note that these must not
3000        be used if the interval var is unperformed.
3001        """
3002        return _pywrapcp.IntervalVar_StartExpr(self)

These methods create expressions encapsulating the start, end and duration of the interval var. Please note that these must not be used if the interval var is unperformed.

def DurationExpr(self):
3004    def DurationExpr(self):
3005        return _pywrapcp.IntervalVar_DurationExpr(self)
def EndExpr(self):
3007    def EndExpr(self):
3008        return _pywrapcp.IntervalVar_EndExpr(self)
def PerformedExpr(self):
3010    def PerformedExpr(self):
3011        return _pywrapcp.IntervalVar_PerformedExpr(self)
def SafeStartExpr(self, unperformed_value):
3013    def SafeStartExpr(self, unperformed_value):
3014        r"""
3015        These methods create expressions encapsulating the start, end
3016        and duration of the interval var. If the interval var is
3017        unperformed, they will return the unperformed_value.
3018        """
3019        return _pywrapcp.IntervalVar_SafeStartExpr(self, unperformed_value)

These methods create expressions encapsulating the start, end and duration of the interval var. If the interval var is unperformed, they will return the unperformed_value.

def SafeDurationExpr(self, unperformed_value):
3021    def SafeDurationExpr(self, unperformed_value):
3022        return _pywrapcp.IntervalVar_SafeDurationExpr(self, unperformed_value)
def SafeEndExpr(self, unperformed_value):
3024    def SafeEndExpr(self, unperformed_value):
3025        return _pywrapcp.IntervalVar_SafeEndExpr(self, unperformed_value)
def EndsAfterEnd(self, other):
3027    def EndsAfterEnd(self, other):
3028        return _pywrapcp.IntervalVar_EndsAfterEnd(self, other)
def EndsAfterEndWithDelay(self, other, delay):
3030    def EndsAfterEndWithDelay(self, other, delay):
3031        return _pywrapcp.IntervalVar_EndsAfterEndWithDelay(self, other, delay)
def EndsAfterStart(self, other):
3033    def EndsAfterStart(self, other):
3034        return _pywrapcp.IntervalVar_EndsAfterStart(self, other)
def EndsAfterStartWithDelay(self, other, delay):
3036    def EndsAfterStartWithDelay(self, other, delay):
3037        return _pywrapcp.IntervalVar_EndsAfterStartWithDelay(self, other, delay)
def EndsAtEnd(self, other):
3039    def EndsAtEnd(self, other):
3040        return _pywrapcp.IntervalVar_EndsAtEnd(self, other)
def EndsAtEndWithDelay(self, other, delay):
3042    def EndsAtEndWithDelay(self, other, delay):
3043        return _pywrapcp.IntervalVar_EndsAtEndWithDelay(self, other, delay)
def EndsAtStart(self, other):
3045    def EndsAtStart(self, other):
3046        return _pywrapcp.IntervalVar_EndsAtStart(self, other)
def EndsAtStartWithDelay(self, other, delay):
3048    def EndsAtStartWithDelay(self, other, delay):
3049        return _pywrapcp.IntervalVar_EndsAtStartWithDelay(self, other, delay)
def StartsAfterEnd(self, other):
3051    def StartsAfterEnd(self, other):
3052        return _pywrapcp.IntervalVar_StartsAfterEnd(self, other)
def StartsAfterEndWithDelay(self, other, delay):
3054    def StartsAfterEndWithDelay(self, other, delay):
3055        return _pywrapcp.IntervalVar_StartsAfterEndWithDelay(self, other, delay)
def StartsAfterStart(self, other):
3057    def StartsAfterStart(self, other):
3058        return _pywrapcp.IntervalVar_StartsAfterStart(self, other)
def StartsAfterStartWithDelay(self, other, delay):
3060    def StartsAfterStartWithDelay(self, other, delay):
3061        return _pywrapcp.IntervalVar_StartsAfterStartWithDelay(self, other, delay)
def StartsAtEnd(self, other):
3063    def StartsAtEnd(self, other):
3064        return _pywrapcp.IntervalVar_StartsAtEnd(self, other)
def StartsAtEndWithDelay(self, other, delay):
3066    def StartsAtEndWithDelay(self, other, delay):
3067        return _pywrapcp.IntervalVar_StartsAtEndWithDelay(self, other, delay)
def StartsAtStart(self, other):
3069    def StartsAtStart(self, other):
3070        return _pywrapcp.IntervalVar_StartsAtStart(self, other)
def StartsAtStartWithDelay(self, other, delay):
3072    def StartsAtStartWithDelay(self, other, delay):
3073        return _pywrapcp.IntervalVar_StartsAtStartWithDelay(self, other, delay)
def StaysInSync(self, other):
3075    def StaysInSync(self, other):
3076        return _pywrapcp.IntervalVar_StaysInSync(self, other)
def StaysInSyncWithDelay(self, other, delay):
3078    def StaysInSyncWithDelay(self, other, delay):
3079        return _pywrapcp.IntervalVar_StaysInSyncWithDelay(self, other, delay)
def EndsAfter(self, date):
3081    def EndsAfter(self, date):
3082        return _pywrapcp.IntervalVar_EndsAfter(self, date)
def EndsAt(self, date):
3084    def EndsAt(self, date):
3085        return _pywrapcp.IntervalVar_EndsAt(self, date)
def EndsBefore(self, date):
3087    def EndsBefore(self, date):
3088        return _pywrapcp.IntervalVar_EndsBefore(self, date)
def StartsAfter(self, date):
3090    def StartsAfter(self, date):
3091        return _pywrapcp.IntervalVar_StartsAfter(self, date)
def StartsAt(self, date):
3093    def StartsAt(self, date):
3094        return _pywrapcp.IntervalVar_StartsAt(self, date)
def StartsBefore(self, date):
3096    def StartsBefore(self, date):
3097        return _pywrapcp.IntervalVar_StartsBefore(self, date)
def CrossesDate(self, date):
3099    def CrossesDate(self, date):
3100        return _pywrapcp.IntervalVar_CrossesDate(self, date)
def AvoidsDate(self, date):
3102    def AvoidsDate(self, date):
3103        return _pywrapcp.IntervalVar_AvoidsDate(self, date)
class SequenceVar(PropagationBaseObject):
3113class SequenceVar(PropagationBaseObject):
3114    r"""
3115    A sequence variable is a variable whose domain is a set of possible
3116    orderings of the interval variables. It allows ordering of tasks. It
3117    has two sets of methods: ComputePossibleFirstsAndLasts(), which
3118    returns the list of interval variables that can be ranked first or
3119    last; and RankFirst/RankNotFirst/RankLast/RankNotLast, which can be
3120    used to create the search decision.
3121    """
3122
3123    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3124
3125    def __init__(self, *args, **kwargs):
3126        raise AttributeError("No constructor defined")
3127
3128    def DebugString(self):
3129        return _pywrapcp.SequenceVar_DebugString(self)
3130
3131    def RankFirst(self, index):
3132        r"""
3133        Ranks the index_th interval var first of all unranked interval
3134        vars. After that, it will no longer be considered ranked.
3135        """
3136        return _pywrapcp.SequenceVar_RankFirst(self, index)
3137
3138    def RankNotFirst(self, index):
3139        r"""
3140        Indicates that the index_th interval var will not be ranked first
3141        of all currently unranked interval vars.
3142        """
3143        return _pywrapcp.SequenceVar_RankNotFirst(self, index)
3144
3145    def RankLast(self, index):
3146        r"""
3147        Ranks the index_th interval var first of all unranked interval
3148        vars. After that, it will no longer be considered ranked.
3149        """
3150        return _pywrapcp.SequenceVar_RankLast(self, index)
3151
3152    def RankNotLast(self, index):
3153        r"""
3154        Indicates that the index_th interval var will not be ranked first
3155        of all currently unranked interval vars.
3156        """
3157        return _pywrapcp.SequenceVar_RankNotLast(self, index)
3158
3159    def Interval(self, index):
3160        r""" Returns the index_th interval of the sequence."""
3161        return _pywrapcp.SequenceVar_Interval(self, index)
3162
3163    def Next(self, index):
3164        r""" Returns the next of the index_th interval of the sequence."""
3165        return _pywrapcp.SequenceVar_Next(self, index)
3166
3167    def Size(self):
3168        r""" Returns the number of interval vars in the sequence."""
3169        return _pywrapcp.SequenceVar_Size(self)
3170
3171    def __repr__(self):
3172        return _pywrapcp.SequenceVar___repr__(self)
3173
3174    def __str__(self):
3175        return _pywrapcp.SequenceVar___str__(self)

A sequence variable is a variable whose domain is a set of possible orderings of the interval variables. It allows ordering of tasks. It has two sets of methods: ComputePossibleFirstsAndLasts(), which returns the list of interval variables that can be ranked first or last; and RankFirst/RankNotFirst/RankLast/RankNotLast, which can be used to create the search decision.

SequenceVar(*args, **kwargs)
3125    def __init__(self, *args, **kwargs):
3126        raise AttributeError("No constructor defined")
thisown

The membership flag

def DebugString(self):
3128    def DebugString(self):
3129        return _pywrapcp.SequenceVar_DebugString(self)
def RankFirst(self, index):
3131    def RankFirst(self, index):
3132        r"""
3133        Ranks the index_th interval var first of all unranked interval
3134        vars. After that, it will no longer be considered ranked.
3135        """
3136        return _pywrapcp.SequenceVar_RankFirst(self, index)

Ranks the index_th interval var first of all unranked interval vars. After that, it will no longer be considered ranked.

def RankNotFirst(self, index):
3138    def RankNotFirst(self, index):
3139        r"""
3140        Indicates that the index_th interval var will not be ranked first
3141        of all currently unranked interval vars.
3142        """
3143        return _pywrapcp.SequenceVar_RankNotFirst(self, index)

Indicates that the index_th interval var will not be ranked first of all currently unranked interval vars.

def RankLast(self, index):
3145    def RankLast(self, index):
3146        r"""
3147        Ranks the index_th interval var first of all unranked interval
3148        vars. After that, it will no longer be considered ranked.
3149        """
3150        return _pywrapcp.SequenceVar_RankLast(self, index)

Ranks the index_th interval var first of all unranked interval vars. After that, it will no longer be considered ranked.

def RankNotLast(self, index):
3152    def RankNotLast(self, index):
3153        r"""
3154        Indicates that the index_th interval var will not be ranked first
3155        of all currently unranked interval vars.
3156        """
3157        return _pywrapcp.SequenceVar_RankNotLast(self, index)

Indicates that the index_th interval var will not be ranked first of all currently unranked interval vars.

def Interval(self, index):
3159    def Interval(self, index):
3160        r""" Returns the index_th interval of the sequence."""
3161        return _pywrapcp.SequenceVar_Interval(self, index)

Returns the index_th interval of the sequence.

def Next(self, index):
3163    def Next(self, index):
3164        r""" Returns the next of the index_th interval of the sequence."""
3165        return _pywrapcp.SequenceVar_Next(self, index)

Returns the next of the index_th interval of the sequence.

def Size(self):
3167    def Size(self):
3168        r""" Returns the number of interval vars in the sequence."""
3169        return _pywrapcp.SequenceVar_Size(self)

Returns the number of interval vars in the sequence.

Inherited Members
PropagationBaseObject
solver
Name
class AssignmentElement:
3179class AssignmentElement(object):
3180    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3181
3182    def __init__(self, *args, **kwargs):
3183        raise AttributeError("No constructor defined")
3184    __repr__ = _swig_repr
3185
3186    def Activate(self):
3187        return _pywrapcp.AssignmentElement_Activate(self)
3188
3189    def Deactivate(self):
3190        return _pywrapcp.AssignmentElement_Deactivate(self)
3191
3192    def Activated(self):
3193        return _pywrapcp.AssignmentElement_Activated(self)
3194    __swig_destroy__ = _pywrapcp.delete_AssignmentElement
AssignmentElement(*args, **kwargs)
3182    def __init__(self, *args, **kwargs):
3183        raise AttributeError("No constructor defined")
thisown

The membership flag

def Activate(self):
3186    def Activate(self):
3187        return _pywrapcp.AssignmentElement_Activate(self)
def Deactivate(self):
3189    def Deactivate(self):
3190        return _pywrapcp.AssignmentElement_Deactivate(self)
def Activated(self):
3192    def Activated(self):
3193        return _pywrapcp.AssignmentElement_Activated(self)
class IntVarElement(AssignmentElement):
3198class IntVarElement(AssignmentElement):
3199    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3200
3201    def __init__(self, *args, **kwargs):
3202        raise AttributeError("No constructor defined")
3203    __repr__ = _swig_repr
3204
3205    def Var(self):
3206        return _pywrapcp.IntVarElement_Var(self)
3207
3208    def Min(self):
3209        return _pywrapcp.IntVarElement_Min(self)
3210
3211    def SetMin(self, m):
3212        return _pywrapcp.IntVarElement_SetMin(self, m)
3213
3214    def Max(self):
3215        return _pywrapcp.IntVarElement_Max(self)
3216
3217    def SetMax(self, m):
3218        return _pywrapcp.IntVarElement_SetMax(self, m)
3219
3220    def Value(self):
3221        return _pywrapcp.IntVarElement_Value(self)
3222
3223    def Bound(self):
3224        return _pywrapcp.IntVarElement_Bound(self)
3225
3226    def SetRange(self, l, u):
3227        return _pywrapcp.IntVarElement_SetRange(self, l, u)
3228
3229    def SetValue(self, v):
3230        return _pywrapcp.IntVarElement_SetValue(self, v)
3231
3232    def __eq__(self, element):
3233        return _pywrapcp.IntVarElement___eq__(self, element)
3234
3235    def __ne__(self, element):
3236        return _pywrapcp.IntVarElement___ne__(self, element)
3237    __swig_destroy__ = _pywrapcp.delete_IntVarElement
IntVarElement(*args, **kwargs)
3201    def __init__(self, *args, **kwargs):
3202        raise AttributeError("No constructor defined")
thisown

The membership flag

def Var(self):
3205    def Var(self):
3206        return _pywrapcp.IntVarElement_Var(self)
def Min(self):
3208    def Min(self):
3209        return _pywrapcp.IntVarElement_Min(self)
def SetMin(self, m):
3211    def SetMin(self, m):
3212        return _pywrapcp.IntVarElement_SetMin(self, m)
def Max(self):
3214    def Max(self):
3215        return _pywrapcp.IntVarElement_Max(self)
def SetMax(self, m):
3217    def SetMax(self, m):
3218        return _pywrapcp.IntVarElement_SetMax(self, m)
def Value(self):
3220    def Value(self):
3221        return _pywrapcp.IntVarElement_Value(self)
def Bound(self):
3223    def Bound(self):
3224        return _pywrapcp.IntVarElement_Bound(self)
def SetRange(self, l, u):
3226    def SetRange(self, l, u):
3227        return _pywrapcp.IntVarElement_SetRange(self, l, u)
def SetValue(self, v):
3229    def SetValue(self, v):
3230        return _pywrapcp.IntVarElement_SetValue(self, v)
class IntervalVarElement(AssignmentElement):
3241class IntervalVarElement(AssignmentElement):
3242    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3243
3244    def __init__(self, *args, **kwargs):
3245        raise AttributeError("No constructor defined")
3246    __repr__ = _swig_repr
3247
3248    def Var(self):
3249        return _pywrapcp.IntervalVarElement_Var(self)
3250
3251    def StartMin(self):
3252        return _pywrapcp.IntervalVarElement_StartMin(self)
3253
3254    def StartMax(self):
3255        return _pywrapcp.IntervalVarElement_StartMax(self)
3256
3257    def StartValue(self):
3258        return _pywrapcp.IntervalVarElement_StartValue(self)
3259
3260    def DurationMin(self):
3261        return _pywrapcp.IntervalVarElement_DurationMin(self)
3262
3263    def DurationMax(self):
3264        return _pywrapcp.IntervalVarElement_DurationMax(self)
3265
3266    def DurationValue(self):
3267        return _pywrapcp.IntervalVarElement_DurationValue(self)
3268
3269    def EndMin(self):
3270        return _pywrapcp.IntervalVarElement_EndMin(self)
3271
3272    def EndMax(self):
3273        return _pywrapcp.IntervalVarElement_EndMax(self)
3274
3275    def EndValue(self):
3276        return _pywrapcp.IntervalVarElement_EndValue(self)
3277
3278    def PerformedMin(self):
3279        return _pywrapcp.IntervalVarElement_PerformedMin(self)
3280
3281    def PerformedMax(self):
3282        return _pywrapcp.IntervalVarElement_PerformedMax(self)
3283
3284    def PerformedValue(self):
3285        return _pywrapcp.IntervalVarElement_PerformedValue(self)
3286
3287    def SetStartMin(self, m):
3288        return _pywrapcp.IntervalVarElement_SetStartMin(self, m)
3289
3290    def SetStartMax(self, m):
3291        return _pywrapcp.IntervalVarElement_SetStartMax(self, m)
3292
3293    def SetStartRange(self, mi, ma):
3294        return _pywrapcp.IntervalVarElement_SetStartRange(self, mi, ma)
3295
3296    def SetStartValue(self, v):
3297        return _pywrapcp.IntervalVarElement_SetStartValue(self, v)
3298
3299    def SetDurationMin(self, m):
3300        return _pywrapcp.IntervalVarElement_SetDurationMin(self, m)
3301
3302    def SetDurationMax(self, m):
3303        return _pywrapcp.IntervalVarElement_SetDurationMax(self, m)
3304
3305    def SetDurationRange(self, mi, ma):
3306        return _pywrapcp.IntervalVarElement_SetDurationRange(self, mi, ma)
3307
3308    def SetDurationValue(self, v):
3309        return _pywrapcp.IntervalVarElement_SetDurationValue(self, v)
3310
3311    def SetEndMin(self, m):
3312        return _pywrapcp.IntervalVarElement_SetEndMin(self, m)
3313
3314    def SetEndMax(self, m):
3315        return _pywrapcp.IntervalVarElement_SetEndMax(self, m)
3316
3317    def SetEndRange(self, mi, ma):
3318        return _pywrapcp.IntervalVarElement_SetEndRange(self, mi, ma)
3319
3320    def SetEndValue(self, v):
3321        return _pywrapcp.IntervalVarElement_SetEndValue(self, v)
3322
3323    def SetPerformedMin(self, m):
3324        return _pywrapcp.IntervalVarElement_SetPerformedMin(self, m)
3325
3326    def SetPerformedMax(self, m):
3327        return _pywrapcp.IntervalVarElement_SetPerformedMax(self, m)
3328
3329    def SetPerformedRange(self, mi, ma):
3330        return _pywrapcp.IntervalVarElement_SetPerformedRange(self, mi, ma)
3331
3332    def SetPerformedValue(self, v):
3333        return _pywrapcp.IntervalVarElement_SetPerformedValue(self, v)
3334
3335    def __eq__(self, element):
3336        return _pywrapcp.IntervalVarElement___eq__(self, element)
3337
3338    def __ne__(self, element):
3339        return _pywrapcp.IntervalVarElement___ne__(self, element)
3340    __swig_destroy__ = _pywrapcp.delete_IntervalVarElement
IntervalVarElement(*args, **kwargs)
3244    def __init__(self, *args, **kwargs):
3245        raise AttributeError("No constructor defined")
thisown

The membership flag

def Var(self):
3248    def Var(self):
3249        return _pywrapcp.IntervalVarElement_Var(self)
def StartMin(self):
3251    def StartMin(self):
3252        return _pywrapcp.IntervalVarElement_StartMin(self)
def StartMax(self):
3254    def StartMax(self):
3255        return _pywrapcp.IntervalVarElement_StartMax(self)
def StartValue(self):
3257    def StartValue(self):
3258        return _pywrapcp.IntervalVarElement_StartValue(self)
def DurationMin(self):
3260    def DurationMin(self):
3261        return _pywrapcp.IntervalVarElement_DurationMin(self)
def DurationMax(self):
3263    def DurationMax(self):
3264        return _pywrapcp.IntervalVarElement_DurationMax(self)
def DurationValue(self):
3266    def DurationValue(self):
3267        return _pywrapcp.IntervalVarElement_DurationValue(self)
def EndMin(self):
3269    def EndMin(self):
3270        return _pywrapcp.IntervalVarElement_EndMin(self)
def EndMax(self):
3272    def EndMax(self):
3273        return _pywrapcp.IntervalVarElement_EndMax(self)
def EndValue(self):
3275    def EndValue(self):
3276        return _pywrapcp.IntervalVarElement_EndValue(self)
def PerformedMin(self):
3278    def PerformedMin(self):
3279        return _pywrapcp.IntervalVarElement_PerformedMin(self)
def PerformedMax(self):
3281    def PerformedMax(self):
3282        return _pywrapcp.IntervalVarElement_PerformedMax(self)
def PerformedValue(self):
3284    def PerformedValue(self):
3285        return _pywrapcp.IntervalVarElement_PerformedValue(self)
def SetStartMin(self, m):
3287    def SetStartMin(self, m):
3288        return _pywrapcp.IntervalVarElement_SetStartMin(self, m)
def SetStartMax(self, m):
3290    def SetStartMax(self, m):
3291        return _pywrapcp.IntervalVarElement_SetStartMax(self, m)
def SetStartRange(self, mi, ma):
3293    def SetStartRange(self, mi, ma):
3294        return _pywrapcp.IntervalVarElement_SetStartRange(self, mi, ma)
def SetStartValue(self, v):
3296    def SetStartValue(self, v):
3297        return _pywrapcp.IntervalVarElement_SetStartValue(self, v)
def SetDurationMin(self, m):
3299    def SetDurationMin(self, m):
3300        return _pywrapcp.IntervalVarElement_SetDurationMin(self, m)
def SetDurationMax(self, m):
3302    def SetDurationMax(self, m):
3303        return _pywrapcp.IntervalVarElement_SetDurationMax(self, m)
def SetDurationRange(self, mi, ma):
3305    def SetDurationRange(self, mi, ma):
3306        return _pywrapcp.IntervalVarElement_SetDurationRange(self, mi, ma)
def SetDurationValue(self, v):
3308    def SetDurationValue(self, v):
3309        return _pywrapcp.IntervalVarElement_SetDurationValue(self, v)
def SetEndMin(self, m):
3311    def SetEndMin(self, m):
3312        return _pywrapcp.IntervalVarElement_SetEndMin(self, m)
def SetEndMax(self, m):
3314    def SetEndMax(self, m):
3315        return _pywrapcp.IntervalVarElement_SetEndMax(self, m)
def SetEndRange(self, mi, ma):
3317    def SetEndRange(self, mi, ma):
3318        return _pywrapcp.IntervalVarElement_SetEndRange(self, mi, ma)
def SetEndValue(self, v):
3320    def SetEndValue(self, v):
3321        return _pywrapcp.IntervalVarElement_SetEndValue(self, v)
def SetPerformedMin(self, m):
3323    def SetPerformedMin(self, m):
3324        return _pywrapcp.IntervalVarElement_SetPerformedMin(self, m)
def SetPerformedMax(self, m):
3326    def SetPerformedMax(self, m):
3327        return _pywrapcp.IntervalVarElement_SetPerformedMax(self, m)
def SetPerformedRange(self, mi, ma):
3329    def SetPerformedRange(self, mi, ma):
3330        return _pywrapcp.IntervalVarElement_SetPerformedRange(self, mi, ma)
def SetPerformedValue(self, v):
3332    def SetPerformedValue(self, v):
3333        return _pywrapcp.IntervalVarElement_SetPerformedValue(self, v)
class SequenceVarElement(AssignmentElement):
3344class SequenceVarElement(AssignmentElement):
3345    r"""
3346    The SequenceVarElement stores a partial representation of ranked
3347    interval variables in the underlying sequence variable.
3348    This representation consists of three vectors:
3349      - the forward sequence. That is the list of interval variables
3350        ranked first in the sequence.  The first element of the backward
3351        sequence is the first interval in the sequence variable.
3352      - the backward sequence. That is the list of interval variables
3353        ranked last in the sequence. The first element of the backward
3354        sequence is the last interval in the sequence variable.
3355      - The list of unperformed interval variables.
3356     Furthermore, if all performed variables are ranked, then by
3357     convention, the forward_sequence will contain all such variables
3358     and the backward_sequence will be empty.
3359    """
3360
3361    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3362
3363    def __init__(self, *args, **kwargs):
3364        raise AttributeError("No constructor defined")
3365    __repr__ = _swig_repr
3366
3367    def Var(self):
3368        return _pywrapcp.SequenceVarElement_Var(self)
3369
3370    def ForwardSequence(self):
3371        return _pywrapcp.SequenceVarElement_ForwardSequence(self)
3372
3373    def BackwardSequence(self):
3374        return _pywrapcp.SequenceVarElement_BackwardSequence(self)
3375
3376    def Unperformed(self):
3377        return _pywrapcp.SequenceVarElement_Unperformed(self)
3378
3379    def SetSequence(self, forward_sequence, backward_sequence, unperformed):
3380        return _pywrapcp.SequenceVarElement_SetSequence(self, forward_sequence, backward_sequence, unperformed)
3381
3382    def SetForwardSequence(self, forward_sequence):
3383        return _pywrapcp.SequenceVarElement_SetForwardSequence(self, forward_sequence)
3384
3385    def SetBackwardSequence(self, backward_sequence):
3386        return _pywrapcp.SequenceVarElement_SetBackwardSequence(self, backward_sequence)
3387
3388    def SetUnperformed(self, unperformed):
3389        return _pywrapcp.SequenceVarElement_SetUnperformed(self, unperformed)
3390
3391    def __eq__(self, element):
3392        return _pywrapcp.SequenceVarElement___eq__(self, element)
3393
3394    def __ne__(self, element):
3395        return _pywrapcp.SequenceVarElement___ne__(self, element)
3396    __swig_destroy__ = _pywrapcp.delete_SequenceVarElement

The SequenceVarElement stores a partial representation of ranked interval variables in the underlying sequence variable.

This representation consists of three vectors:
  • the forward sequence. That is the list of interval variables ranked first in the sequence. The first element of the backward sequence is the first interval in the sequence variable.
    • the backward sequence. That is the list of interval variables ranked last in the sequence. The first element of the backward sequence is the last interval in the sequence variable.
    • The list of unperformed interval variables. Furthermore, if all performed variables are ranked, then by convention, the forward_sequence will contain all such variables and the backward_sequence will be empty.
SequenceVarElement(*args, **kwargs)
3363    def __init__(self, *args, **kwargs):
3364        raise AttributeError("No constructor defined")
thisown

The membership flag

def Var(self):
3367    def Var(self):
3368        return _pywrapcp.SequenceVarElement_Var(self)
def ForwardSequence(self):
3370    def ForwardSequence(self):
3371        return _pywrapcp.SequenceVarElement_ForwardSequence(self)
def BackwardSequence(self):
3373    def BackwardSequence(self):
3374        return _pywrapcp.SequenceVarElement_BackwardSequence(self)
def Unperformed(self):
3376    def Unperformed(self):
3377        return _pywrapcp.SequenceVarElement_Unperformed(self)
def SetSequence(self, forward_sequence, backward_sequence, unperformed):
3379    def SetSequence(self, forward_sequence, backward_sequence, unperformed):
3380        return _pywrapcp.SequenceVarElement_SetSequence(self, forward_sequence, backward_sequence, unperformed)
def SetForwardSequence(self, forward_sequence):
3382    def SetForwardSequence(self, forward_sequence):
3383        return _pywrapcp.SequenceVarElement_SetForwardSequence(self, forward_sequence)
def SetBackwardSequence(self, backward_sequence):
3385    def SetBackwardSequence(self, backward_sequence):
3386        return _pywrapcp.SequenceVarElement_SetBackwardSequence(self, backward_sequence)
def SetUnperformed(self, unperformed):
3388    def SetUnperformed(self, unperformed):
3389        return _pywrapcp.SequenceVarElement_SetUnperformed(self, unperformed)
class Assignment(PropagationBaseObject):
3400class Assignment(PropagationBaseObject):
3401    r"""
3402    An Assignment is a variable -> domains mapping, used
3403    to report solutions to the user.
3404    """
3405
3406    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3407
3408    def __init__(self, *args, **kwargs):
3409        raise AttributeError("No constructor defined")
3410    __repr__ = _swig_repr
3411
3412    def Clear(self):
3413        return _pywrapcp.Assignment_Clear(self)
3414
3415    def Empty(self):
3416        return _pywrapcp.Assignment_Empty(self)
3417
3418    def Size(self):
3419        return _pywrapcp.Assignment_Size(self)
3420
3421    def NumIntVars(self):
3422        return _pywrapcp.Assignment_NumIntVars(self)
3423
3424    def NumIntervalVars(self):
3425        return _pywrapcp.Assignment_NumIntervalVars(self)
3426
3427    def NumSequenceVars(self):
3428        return _pywrapcp.Assignment_NumSequenceVars(self)
3429
3430    def Store(self):
3431        return _pywrapcp.Assignment_Store(self)
3432
3433    def Restore(self):
3434        return _pywrapcp.Assignment_Restore(self)
3435
3436    def Load(self, *args):
3437        return _pywrapcp.Assignment_Load(self, *args)
3438
3439    def Save(self, *args):
3440        return _pywrapcp.Assignment_Save(self, *args)
3441
3442    def AddObjective(self, v):
3443        return _pywrapcp.Assignment_AddObjective(self, v)
3444
3445    def Objective(self):
3446        return _pywrapcp.Assignment_Objective(self)
3447
3448    def HasObjective(self):
3449        return _pywrapcp.Assignment_HasObjective(self)
3450
3451    def ObjectiveMin(self):
3452        return _pywrapcp.Assignment_ObjectiveMin(self)
3453
3454    def ObjectiveMax(self):
3455        return _pywrapcp.Assignment_ObjectiveMax(self)
3456
3457    def ObjectiveValue(self):
3458        return _pywrapcp.Assignment_ObjectiveValue(self)
3459
3460    def ObjectiveBound(self):
3461        return _pywrapcp.Assignment_ObjectiveBound(self)
3462
3463    def SetObjectiveMin(self, m):
3464        return _pywrapcp.Assignment_SetObjectiveMin(self, m)
3465
3466    def SetObjectiveMax(self, m):
3467        return _pywrapcp.Assignment_SetObjectiveMax(self, m)
3468
3469    def SetObjectiveValue(self, value):
3470        return _pywrapcp.Assignment_SetObjectiveValue(self, value)
3471
3472    def SetObjectiveRange(self, l, u):
3473        return _pywrapcp.Assignment_SetObjectiveRange(self, l, u)
3474
3475    def Min(self, var):
3476        return _pywrapcp.Assignment_Min(self, var)
3477
3478    def Max(self, var):
3479        return _pywrapcp.Assignment_Max(self, var)
3480
3481    def Value(self, var):
3482        return _pywrapcp.Assignment_Value(self, var)
3483
3484    def Bound(self, var):
3485        return _pywrapcp.Assignment_Bound(self, var)
3486
3487    def SetMin(self, var, m):
3488        return _pywrapcp.Assignment_SetMin(self, var, m)
3489
3490    def SetMax(self, var, m):
3491        return _pywrapcp.Assignment_SetMax(self, var, m)
3492
3493    def SetRange(self, var, l, u):
3494        return _pywrapcp.Assignment_SetRange(self, var, l, u)
3495
3496    def SetValue(self, var, value):
3497        return _pywrapcp.Assignment_SetValue(self, var, value)
3498
3499    def StartMin(self, var):
3500        return _pywrapcp.Assignment_StartMin(self, var)
3501
3502    def StartMax(self, var):
3503        return _pywrapcp.Assignment_StartMax(self, var)
3504
3505    def StartValue(self, var):
3506        return _pywrapcp.Assignment_StartValue(self, var)
3507
3508    def DurationMin(self, var):
3509        return _pywrapcp.Assignment_DurationMin(self, var)
3510
3511    def DurationMax(self, var):
3512        return _pywrapcp.Assignment_DurationMax(self, var)
3513
3514    def DurationValue(self, var):
3515        return _pywrapcp.Assignment_DurationValue(self, var)
3516
3517    def EndMin(self, var):
3518        return _pywrapcp.Assignment_EndMin(self, var)
3519
3520    def EndMax(self, var):
3521        return _pywrapcp.Assignment_EndMax(self, var)
3522
3523    def EndValue(self, var):
3524        return _pywrapcp.Assignment_EndValue(self, var)
3525
3526    def PerformedMin(self, var):
3527        return _pywrapcp.Assignment_PerformedMin(self, var)
3528
3529    def PerformedMax(self, var):
3530        return _pywrapcp.Assignment_PerformedMax(self, var)
3531
3532    def PerformedValue(self, var):
3533        return _pywrapcp.Assignment_PerformedValue(self, var)
3534
3535    def SetStartMin(self, var, m):
3536        return _pywrapcp.Assignment_SetStartMin(self, var, m)
3537
3538    def SetStartMax(self, var, m):
3539        return _pywrapcp.Assignment_SetStartMax(self, var, m)
3540
3541    def SetStartRange(self, var, mi, ma):
3542        return _pywrapcp.Assignment_SetStartRange(self, var, mi, ma)
3543
3544    def SetStartValue(self, var, value):
3545        return _pywrapcp.Assignment_SetStartValue(self, var, value)
3546
3547    def SetDurationMin(self, var, m):
3548        return _pywrapcp.Assignment_SetDurationMin(self, var, m)
3549
3550    def SetDurationMax(self, var, m):
3551        return _pywrapcp.Assignment_SetDurationMax(self, var, m)
3552
3553    def SetDurationRange(self, var, mi, ma):
3554        return _pywrapcp.Assignment_SetDurationRange(self, var, mi, ma)
3555
3556    def SetDurationValue(self, var, value):
3557        return _pywrapcp.Assignment_SetDurationValue(self, var, value)
3558
3559    def SetEndMin(self, var, m):
3560        return _pywrapcp.Assignment_SetEndMin(self, var, m)
3561
3562    def SetEndMax(self, var, m):
3563        return _pywrapcp.Assignment_SetEndMax(self, var, m)
3564
3565    def SetEndRange(self, var, mi, ma):
3566        return _pywrapcp.Assignment_SetEndRange(self, var, mi, ma)
3567
3568    def SetEndValue(self, var, value):
3569        return _pywrapcp.Assignment_SetEndValue(self, var, value)
3570
3571    def SetPerformedMin(self, var, m):
3572        return _pywrapcp.Assignment_SetPerformedMin(self, var, m)
3573
3574    def SetPerformedMax(self, var, m):
3575        return _pywrapcp.Assignment_SetPerformedMax(self, var, m)
3576
3577    def SetPerformedRange(self, var, mi, ma):
3578        return _pywrapcp.Assignment_SetPerformedRange(self, var, mi, ma)
3579
3580    def SetPerformedValue(self, var, value):
3581        return _pywrapcp.Assignment_SetPerformedValue(self, var, value)
3582
3583    def Add(self, *args):
3584        return _pywrapcp.Assignment_Add(self, *args)
3585
3586    def ForwardSequence(self, var):
3587        return _pywrapcp.Assignment_ForwardSequence(self, var)
3588
3589    def BackwardSequence(self, var):
3590        return _pywrapcp.Assignment_BackwardSequence(self, var)
3591
3592    def Unperformed(self, var):
3593        return _pywrapcp.Assignment_Unperformed(self, var)
3594
3595    def SetSequence(self, var, forward_sequence, backward_sequence, unperformed):
3596        return _pywrapcp.Assignment_SetSequence(self, var, forward_sequence, backward_sequence, unperformed)
3597
3598    def SetForwardSequence(self, var, forward_sequence):
3599        return _pywrapcp.Assignment_SetForwardSequence(self, var, forward_sequence)
3600
3601    def SetBackwardSequence(self, var, backward_sequence):
3602        return _pywrapcp.Assignment_SetBackwardSequence(self, var, backward_sequence)
3603
3604    def SetUnperformed(self, var, unperformed):
3605        return _pywrapcp.Assignment_SetUnperformed(self, var, unperformed)
3606
3607    def Activate(self, *args):
3608        return _pywrapcp.Assignment_Activate(self, *args)
3609
3610    def Deactivate(self, *args):
3611        return _pywrapcp.Assignment_Deactivate(self, *args)
3612
3613    def Activated(self, *args):
3614        return _pywrapcp.Assignment_Activated(self, *args)
3615
3616    def DebugString(self):
3617        return _pywrapcp.Assignment_DebugString(self)
3618
3619    def IntVarContainer(self):
3620        return _pywrapcp.Assignment_IntVarContainer(self)
3621
3622    def MutableIntVarContainer(self):
3623        return _pywrapcp.Assignment_MutableIntVarContainer(self)
3624
3625    def IntervalVarContainer(self):
3626        return _pywrapcp.Assignment_IntervalVarContainer(self)
3627
3628    def MutableIntervalVarContainer(self):
3629        return _pywrapcp.Assignment_MutableIntervalVarContainer(self)
3630
3631    def SequenceVarContainer(self):
3632        return _pywrapcp.Assignment_SequenceVarContainer(self)
3633
3634    def MutableSequenceVarContainer(self):
3635        return _pywrapcp.Assignment_MutableSequenceVarContainer(self)
3636
3637    def __eq__(self, assignment):
3638        return _pywrapcp.Assignment___eq__(self, assignment)
3639
3640    def __ne__(self, assignment):
3641        return _pywrapcp.Assignment___ne__(self, assignment)

An Assignment is a variable -> domains mapping, used to report solutions to the user.

Assignment(*args, **kwargs)
3408    def __init__(self, *args, **kwargs):
3409        raise AttributeError("No constructor defined")
thisown

The membership flag

def Clear(self):
3412    def Clear(self):
3413        return _pywrapcp.Assignment_Clear(self)
def Empty(self):
3415    def Empty(self):
3416        return _pywrapcp.Assignment_Empty(self)
def Size(self):
3418    def Size(self):
3419        return _pywrapcp.Assignment_Size(self)
def NumIntVars(self):
3421    def NumIntVars(self):
3422        return _pywrapcp.Assignment_NumIntVars(self)
def NumIntervalVars(self):
3424    def NumIntervalVars(self):
3425        return _pywrapcp.Assignment_NumIntervalVars(self)
def NumSequenceVars(self):
3427    def NumSequenceVars(self):
3428        return _pywrapcp.Assignment_NumSequenceVars(self)
def Store(self):
3430    def Store(self):
3431        return _pywrapcp.Assignment_Store(self)
def Restore(self):
3433    def Restore(self):
3434        return _pywrapcp.Assignment_Restore(self)
def Load(self, *args):
3436    def Load(self, *args):
3437        return _pywrapcp.Assignment_Load(self, *args)
def Save(self, *args):
3439    def Save(self, *args):
3440        return _pywrapcp.Assignment_Save(self, *args)
def AddObjective(self, v):
3442    def AddObjective(self, v):
3443        return _pywrapcp.Assignment_AddObjective(self, v)
def Objective(self):
3445    def Objective(self):
3446        return _pywrapcp.Assignment_Objective(self)
def HasObjective(self):
3448    def HasObjective(self):
3449        return _pywrapcp.Assignment_HasObjective(self)
def ObjectiveMin(self):
3451    def ObjectiveMin(self):
3452        return _pywrapcp.Assignment_ObjectiveMin(self)
def ObjectiveMax(self):
3454    def ObjectiveMax(self):
3455        return _pywrapcp.Assignment_ObjectiveMax(self)
def ObjectiveValue(self):
3457    def ObjectiveValue(self):
3458        return _pywrapcp.Assignment_ObjectiveValue(self)
def ObjectiveBound(self):
3460    def ObjectiveBound(self):
3461        return _pywrapcp.Assignment_ObjectiveBound(self)
def SetObjectiveMin(self, m):
3463    def SetObjectiveMin(self, m):
3464        return _pywrapcp.Assignment_SetObjectiveMin(self, m)
def SetObjectiveMax(self, m):
3466    def SetObjectiveMax(self, m):
3467        return _pywrapcp.Assignment_SetObjectiveMax(self, m)
def SetObjectiveValue(self, value):
3469    def SetObjectiveValue(self, value):
3470        return _pywrapcp.Assignment_SetObjectiveValue(self, value)
def SetObjectiveRange(self, l, u):
3472    def SetObjectiveRange(self, l, u):
3473        return _pywrapcp.Assignment_SetObjectiveRange(self, l, u)
def Min(self, var):
3475    def Min(self, var):
3476        return _pywrapcp.Assignment_Min(self, var)
def Max(self, var):
3478    def Max(self, var):
3479        return _pywrapcp.Assignment_Max(self, var)
def Value(self, var):
3481    def Value(self, var):
3482        return _pywrapcp.Assignment_Value(self, var)
def Bound(self, var):
3484    def Bound(self, var):
3485        return _pywrapcp.Assignment_Bound(self, var)
def SetMin(self, var, m):
3487    def SetMin(self, var, m):
3488        return _pywrapcp.Assignment_SetMin(self, var, m)
def SetMax(self, var, m):
3490    def SetMax(self, var, m):
3491        return _pywrapcp.Assignment_SetMax(self, var, m)
def SetRange(self, var, l, u):
3493    def SetRange(self, var, l, u):
3494        return _pywrapcp.Assignment_SetRange(self, var, l, u)
def SetValue(self, var, value):
3496    def SetValue(self, var, value):
3497        return _pywrapcp.Assignment_SetValue(self, var, value)
def StartMin(self, var):
3499    def StartMin(self, var):
3500        return _pywrapcp.Assignment_StartMin(self, var)
def StartMax(self, var):
3502    def StartMax(self, var):
3503        return _pywrapcp.Assignment_StartMax(self, var)
def StartValue(self, var):
3505    def StartValue(self, var):
3506        return _pywrapcp.Assignment_StartValue(self, var)
def DurationMin(self, var):
3508    def DurationMin(self, var):
3509        return _pywrapcp.Assignment_DurationMin(self, var)
def DurationMax(self, var):
3511    def DurationMax(self, var):
3512        return _pywrapcp.Assignment_DurationMax(self, var)
def DurationValue(self, var):
3514    def DurationValue(self, var):
3515        return _pywrapcp.Assignment_DurationValue(self, var)
def EndMin(self, var):
3517    def EndMin(self, var):
3518        return _pywrapcp.Assignment_EndMin(self, var)
def EndMax(self, var):
3520    def EndMax(self, var):
3521        return _pywrapcp.Assignment_EndMax(self, var)
def EndValue(self, var):
3523    def EndValue(self, var):
3524        return _pywrapcp.Assignment_EndValue(self, var)
def PerformedMin(self, var):
3526    def PerformedMin(self, var):
3527        return _pywrapcp.Assignment_PerformedMin(self, var)
def PerformedMax(self, var):
3529    def PerformedMax(self, var):
3530        return _pywrapcp.Assignment_PerformedMax(self, var)
def PerformedValue(self, var):
3532    def PerformedValue(self, var):
3533        return _pywrapcp.Assignment_PerformedValue(self, var)
def SetStartMin(self, var, m):
3535    def SetStartMin(self, var, m):
3536        return _pywrapcp.Assignment_SetStartMin(self, var, m)
def SetStartMax(self, var, m):
3538    def SetStartMax(self, var, m):
3539        return _pywrapcp.Assignment_SetStartMax(self, var, m)
def SetStartRange(self, var, mi, ma):
3541    def SetStartRange(self, var, mi, ma):
3542        return _pywrapcp.Assignment_SetStartRange(self, var, mi, ma)
def SetStartValue(self, var, value):
3544    def SetStartValue(self, var, value):
3545        return _pywrapcp.Assignment_SetStartValue(self, var, value)
def SetDurationMin(self, var, m):
3547    def SetDurationMin(self, var, m):
3548        return _pywrapcp.Assignment_SetDurationMin(self, var, m)
def SetDurationMax(self, var, m):
3550    def SetDurationMax(self, var, m):
3551        return _pywrapcp.Assignment_SetDurationMax(self, var, m)
def SetDurationRange(self, var, mi, ma):
3553    def SetDurationRange(self, var, mi, ma):
3554        return _pywrapcp.Assignment_SetDurationRange(self, var, mi, ma)
def SetDurationValue(self, var, value):
3556    def SetDurationValue(self, var, value):
3557        return _pywrapcp.Assignment_SetDurationValue(self, var, value)
def SetEndMin(self, var, m):
3559    def SetEndMin(self, var, m):
3560        return _pywrapcp.Assignment_SetEndMin(self, var, m)
def SetEndMax(self, var, m):
3562    def SetEndMax(self, var, m):
3563        return _pywrapcp.Assignment_SetEndMax(self, var, m)
def SetEndRange(self, var, mi, ma):
3565    def SetEndRange(self, var, mi, ma):
3566        return _pywrapcp.Assignment_SetEndRange(self, var, mi, ma)
def SetEndValue(self, var, value):
3568    def SetEndValue(self, var, value):
3569        return _pywrapcp.Assignment_SetEndValue(self, var, value)
def SetPerformedMin(self, var, m):
3571    def SetPerformedMin(self, var, m):
3572        return _pywrapcp.Assignment_SetPerformedMin(self, var, m)
def SetPerformedMax(self, var, m):
3574    def SetPerformedMax(self, var, m):
3575        return _pywrapcp.Assignment_SetPerformedMax(self, var, m)
def SetPerformedRange(self, var, mi, ma):
3577    def SetPerformedRange(self, var, mi, ma):
3578        return _pywrapcp.Assignment_SetPerformedRange(self, var, mi, ma)
def SetPerformedValue(self, var, value):
3580    def SetPerformedValue(self, var, value):
3581        return _pywrapcp.Assignment_SetPerformedValue(self, var, value)
def Add(self, *args):
3583    def Add(self, *args):
3584        return _pywrapcp.Assignment_Add(self, *args)
def ForwardSequence(self, var):
3586    def ForwardSequence(self, var):
3587        return _pywrapcp.Assignment_ForwardSequence(self, var)
def BackwardSequence(self, var):
3589    def BackwardSequence(self, var):
3590        return _pywrapcp.Assignment_BackwardSequence(self, var)
def Unperformed(self, var):
3592    def Unperformed(self, var):
3593        return _pywrapcp.Assignment_Unperformed(self, var)
def SetSequence(self, var, forward_sequence, backward_sequence, unperformed):
3595    def SetSequence(self, var, forward_sequence, backward_sequence, unperformed):
3596        return _pywrapcp.Assignment_SetSequence(self, var, forward_sequence, backward_sequence, unperformed)
def SetForwardSequence(self, var, forward_sequence):
3598    def SetForwardSequence(self, var, forward_sequence):
3599        return _pywrapcp.Assignment_SetForwardSequence(self, var, forward_sequence)
def SetBackwardSequence(self, var, backward_sequence):
3601    def SetBackwardSequence(self, var, backward_sequence):
3602        return _pywrapcp.Assignment_SetBackwardSequence(self, var, backward_sequence)
def SetUnperformed(self, var, unperformed):
3604    def SetUnperformed(self, var, unperformed):
3605        return _pywrapcp.Assignment_SetUnperformed(self, var, unperformed)
def Activate(self, *args):
3607    def Activate(self, *args):
3608        return _pywrapcp.Assignment_Activate(self, *args)
def Deactivate(self, *args):
3610    def Deactivate(self, *args):
3611        return _pywrapcp.Assignment_Deactivate(self, *args)
def Activated(self, *args):
3613    def Activated(self, *args):
3614        return _pywrapcp.Assignment_Activated(self, *args)
def DebugString(self):
3616    def DebugString(self):
3617        return _pywrapcp.Assignment_DebugString(self)
def IntVarContainer(self):
3619    def IntVarContainer(self):
3620        return _pywrapcp.Assignment_IntVarContainer(self)
def MutableIntVarContainer(self):
3622    def MutableIntVarContainer(self):
3623        return _pywrapcp.Assignment_MutableIntVarContainer(self)
def IntervalVarContainer(self):
3625    def IntervalVarContainer(self):
3626        return _pywrapcp.Assignment_IntervalVarContainer(self)
def MutableIntervalVarContainer(self):
3628    def MutableIntervalVarContainer(self):
3629        return _pywrapcp.Assignment_MutableIntervalVarContainer(self)
def SequenceVarContainer(self):
3631    def SequenceVarContainer(self):
3632        return _pywrapcp.Assignment_SequenceVarContainer(self)
def MutableSequenceVarContainer(self):
3634    def MutableSequenceVarContainer(self):
3635        return _pywrapcp.Assignment_MutableSequenceVarContainer(self)
Inherited Members
PropagationBaseObject
solver
Name
class Pack(Constraint):
3648class Pack(Constraint):
3649    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3650
3651    def __init__(self, *args, **kwargs):
3652        raise AttributeError("No constructor defined")
3653    __repr__ = _swig_repr
3654
3655    def AddWeightedSumLessOrEqualConstantDimension(self, *args):
3656        r"""
3657        *Overload 1:*
3658        Dimensions are additional constraints than can restrict what is
3659        possible with the pack constraint. It can be used to set capacity
3660        limits, to count objects per bin, to compute unassigned
3661        penalties...
3662        This dimension imposes that for all bins b, the weighted sum
3663        (weights[i]) of all objects i assigned to 'b' is less or equal
3664        'bounds[b]'.
3665
3666        |
3667
3668        *Overload 2:*
3669        This dimension imposes that for all bins b, the weighted sum
3670        (weights->Run(i)) of all objects i assigned to 'b' is less or
3671        equal to 'bounds[b]'. Ownership of the callback is transferred to
3672        the pack constraint.
3673
3674        |
3675
3676        *Overload 3:*
3677        This dimension imposes that for all bins b, the weighted sum
3678        (weights->Run(i, b) of all objects i assigned to 'b' is less or
3679        equal to 'bounds[b]'. Ownership of the callback is transferred to
3680        the pack constraint.
3681        """
3682        return _pywrapcp.Pack_AddWeightedSumLessOrEqualConstantDimension(self, *args)
3683
3684    def AddWeightedSumEqualVarDimension(self, *args):
3685        r"""
3686        *Overload 1:*
3687        This dimension imposes that for all bins b, the weighted sum
3688        (weights[i]) of all objects i assigned to 'b' is equal to loads[b].
3689
3690        |
3691
3692        *Overload 2:*
3693        This dimension imposes that for all bins b, the weighted sum
3694        (weights->Run(i, b)) of all objects i assigned to 'b' is equal to
3695        loads[b].
3696        """
3697        return _pywrapcp.Pack_AddWeightedSumEqualVarDimension(self, *args)
3698
3699    def AddSumVariableWeightsLessOrEqualConstantDimension(self, usage, capacity):
3700        r"""
3701        This dimension imposes:
3702        forall b in bins,
3703           sum (i in items: usage[i] * is_assigned(i, b)) <= capacity[b]
3704        where is_assigned(i, b) is true if and only if item i is assigned
3705        to the bin b.
3706
3707        This can be used to model shapes of items by linking variables of
3708        the same item on parallel dimensions with an allowed assignment
3709        constraint.
3710        """
3711        return _pywrapcp.Pack_AddSumVariableWeightsLessOrEqualConstantDimension(self, usage, capacity)
3712
3713    def AddWeightedSumOfAssignedDimension(self, weights, cost_var):
3714        r"""
3715        This dimension enforces that cost_var == sum of weights[i] for
3716        all objects 'i' assigned to a bin.
3717        """
3718        return _pywrapcp.Pack_AddWeightedSumOfAssignedDimension(self, weights, cost_var)
3719
3720    def AddCountUsedBinDimension(self, count_var):
3721        r"""
3722        This dimension links 'count_var' to the actual number of bins used in the
3723        pack.
3724        """
3725        return _pywrapcp.Pack_AddCountUsedBinDimension(self, count_var)
3726
3727    def AddCountAssignedItemsDimension(self, count_var):
3728        r"""
3729        This dimension links 'count_var' to the actual number of items
3730        assigned to a bin in the pack.
3731        """
3732        return _pywrapcp.Pack_AddCountAssignedItemsDimension(self, count_var)
3733
3734    def Post(self):
3735        return _pywrapcp.Pack_Post(self)
3736
3737    def InitialPropagateWrapper(self):
3738        return _pywrapcp.Pack_InitialPropagateWrapper(self)
3739
3740    def DebugString(self):
3741        return _pywrapcp.Pack_DebugString(self)

A constraint is the main modeling object. It provides two methods:

  • Post() is responsible for creating the demons and attaching them to immediate demons().
  • InitialPropagate() is called once just after Post and performs the initial propagation. The subsequent propagations will be performed by the demons Posted during the post() method.
Pack(*args, **kwargs)
3651    def __init__(self, *args, **kwargs):
3652        raise AttributeError("No constructor defined")
thisown

The membership flag

def AddWeightedSumLessOrEqualConstantDimension(self, *args):
3655    def AddWeightedSumLessOrEqualConstantDimension(self, *args):
3656        r"""
3657        *Overload 1:*
3658        Dimensions are additional constraints than can restrict what is
3659        possible with the pack constraint. It can be used to set capacity
3660        limits, to count objects per bin, to compute unassigned
3661        penalties...
3662        This dimension imposes that for all bins b, the weighted sum
3663        (weights[i]) of all objects i assigned to 'b' is less or equal
3664        'bounds[b]'.
3665
3666        |
3667
3668        *Overload 2:*
3669        This dimension imposes that for all bins b, the weighted sum
3670        (weights->Run(i)) of all objects i assigned to 'b' is less or
3671        equal to 'bounds[b]'. Ownership of the callback is transferred to
3672        the pack constraint.
3673
3674        |
3675
3676        *Overload 3:*
3677        This dimension imposes that for all bins b, the weighted sum
3678        (weights->Run(i, b) of all objects i assigned to 'b' is less or
3679        equal to 'bounds[b]'. Ownership of the callback is transferred to
3680        the pack constraint.
3681        """
3682        return _pywrapcp.Pack_AddWeightedSumLessOrEqualConstantDimension(self, *args)

Overload 1: Dimensions are additional constraints than can restrict what is possible with the pack constraint. It can be used to set capacity limits, to count objects per bin, to compute unassigned penalties... This dimension imposes that for all bins b, the weighted sum (weights[i]) of all objects i assigned to 'b' is less or equal 'bounds[b]'.

|

Overload 2: This dimension imposes that for all bins b, the weighted sum (weights->Run(i)) of all objects i assigned to 'b' is less or equal to 'bounds[b]'. Ownership of the callback is transferred to the pack constraint.

|

Overload 3: This dimension imposes that for all bins b, the weighted sum (weights->Run(i, b) of all objects i assigned to 'b' is less or equal to 'bounds[b]'. Ownership of the callback is transferred to the pack constraint.

def AddWeightedSumEqualVarDimension(self, *args):
3684    def AddWeightedSumEqualVarDimension(self, *args):
3685        r"""
3686        *Overload 1:*
3687        This dimension imposes that for all bins b, the weighted sum
3688        (weights[i]) of all objects i assigned to 'b' is equal to loads[b].
3689
3690        |
3691
3692        *Overload 2:*
3693        This dimension imposes that for all bins b, the weighted sum
3694        (weights->Run(i, b)) of all objects i assigned to 'b' is equal to
3695        loads[b].
3696        """
3697        return _pywrapcp.Pack_AddWeightedSumEqualVarDimension(self, *args)

Overload 1: This dimension imposes that for all bins b, the weighted sum (weights[i]) of all objects i assigned to 'b' is equal to loads[b].

|

Overload 2: This dimension imposes that for all bins b, the weighted sum (weights->Run(i, b)) of all objects i assigned to 'b' is equal to loads[b].

def AddSumVariableWeightsLessOrEqualConstantDimension(self, usage, capacity):
3699    def AddSumVariableWeightsLessOrEqualConstantDimension(self, usage, capacity):
3700        r"""
3701        This dimension imposes:
3702        forall b in bins,
3703           sum (i in items: usage[i] * is_assigned(i, b)) <= capacity[b]
3704        where is_assigned(i, b) is true if and only if item i is assigned
3705        to the bin b.
3706
3707        This can be used to model shapes of items by linking variables of
3708        the same item on parallel dimensions with an allowed assignment
3709        constraint.
3710        """
3711        return _pywrapcp.Pack_AddSumVariableWeightsLessOrEqualConstantDimension(self, usage, capacity)

This dimension imposes: forall b in bins, sum (i in items: usage[i] * is_assigned(i, b)) <= capacity[b] where is_assigned(i, b) is true if and only if item i is assigned to the bin b.

This can be used to model shapes of items by linking variables of the same item on parallel dimensions with an allowed assignment constraint.

def AddWeightedSumOfAssignedDimension(self, weights, cost_var):
3713    def AddWeightedSumOfAssignedDimension(self, weights, cost_var):
3714        r"""
3715        This dimension enforces that cost_var == sum of weights[i] for
3716        all objects 'i' assigned to a bin.
3717        """
3718        return _pywrapcp.Pack_AddWeightedSumOfAssignedDimension(self, weights, cost_var)

This dimension enforces that cost_var == sum of weights[i] for all objects 'i' assigned to a bin.

def AddCountUsedBinDimension(self, count_var):
3720    def AddCountUsedBinDimension(self, count_var):
3721        r"""
3722        This dimension links 'count_var' to the actual number of bins used in the
3723        pack.
3724        """
3725        return _pywrapcp.Pack_AddCountUsedBinDimension(self, count_var)

This dimension links 'count_var' to the actual number of bins used in the pack.

def AddCountAssignedItemsDimension(self, count_var):
3727    def AddCountAssignedItemsDimension(self, count_var):
3728        r"""
3729        This dimension links 'count_var' to the actual number of items
3730        assigned to a bin in the pack.
3731        """
3732        return _pywrapcp.Pack_AddCountAssignedItemsDimension(self, count_var)

This dimension links 'count_var' to the actual number of items assigned to a bin in the pack.

def Post(self):
3734    def Post(self):
3735        return _pywrapcp.Pack_Post(self)

This method is called when the constraint is processed by the solver. Its main usage is to attach demons to variables.

def InitialPropagateWrapper(self):
3737    def InitialPropagateWrapper(self):
3738        return _pywrapcp.Pack_InitialPropagateWrapper(self)

This method performs the initial propagation of the constraint. It is called just after the post.

def DebugString(self):
3740    def DebugString(self):
3741        return _pywrapcp.Pack_DebugString(self)
class DisjunctiveConstraint(Constraint):
3745class DisjunctiveConstraint(Constraint):
3746    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3747
3748    def __init__(self, *args, **kwargs):
3749        raise AttributeError("No constructor defined - class is abstract")
3750    __repr__ = _swig_repr
3751
3752    def SequenceVar(self):
3753        r""" Creates a sequence variable from the constraint."""
3754        return _pywrapcp.DisjunctiveConstraint_SequenceVar(self)
3755
3756    def SetTransitionTime(self, transition_time):
3757        r"""
3758        Add a transition time between intervals.  It forces the distance between
3759        the end of interval a and start of interval b that follows it to be at
3760        least transition_time(a, b). This function must always return
3761        a positive or null value.
3762        """
3763        return _pywrapcp.DisjunctiveConstraint_SetTransitionTime(self, transition_time)
3764
3765    def TransitionTime(self, before_index, after_index):
3766        return _pywrapcp.DisjunctiveConstraint_TransitionTime(self, before_index, after_index)

A constraint is the main modeling object. It provides two methods:

  • Post() is responsible for creating the demons and attaching them to immediate demons().
  • InitialPropagate() is called once just after Post and performs the initial propagation. The subsequent propagations will be performed by the demons Posted during the post() method.
DisjunctiveConstraint(*args, **kwargs)
3748    def __init__(self, *args, **kwargs):
3749        raise AttributeError("No constructor defined - class is abstract")
thisown

The membership flag

def SequenceVar(self):
3752    def SequenceVar(self):
3753        r""" Creates a sequence variable from the constraint."""
3754        return _pywrapcp.DisjunctiveConstraint_SequenceVar(self)

Creates a sequence variable from the constraint.

def SetTransitionTime(self, transition_time):
3756    def SetTransitionTime(self, transition_time):
3757        r"""
3758        Add a transition time between intervals.  It forces the distance between
3759        the end of interval a and start of interval b that follows it to be at
3760        least transition_time(a, b). This function must always return
3761        a positive or null value.
3762        """
3763        return _pywrapcp.DisjunctiveConstraint_SetTransitionTime(self, transition_time)

Add a transition time between intervals. It forces the distance between the end of interval a and start of interval b that follows it to be at least transition_time(a, b). This function must always return a positive or null value.

def TransitionTime(self, before_index, after_index):
3765    def TransitionTime(self, before_index, after_index):
3766        return _pywrapcp.DisjunctiveConstraint_TransitionTime(self, before_index, after_index)
class RevInteger:
3770class RevInteger(object):
3771    r"""
3772    This class adds reversibility to a POD type.
3773    It contains the stamp optimization. i.e. the SaveValue call is done
3774    only once per node of the search tree.  Please note that actual
3775    stamps always starts at 1, thus an initial value of 0 will always
3776    trigger the first SaveValue.
3777    """
3778
3779    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3780    __repr__ = _swig_repr
3781
3782    def __init__(self, val):
3783        _pywrapcp.RevInteger_swiginit(self, _pywrapcp.new_RevInteger(val))
3784
3785    def Value(self):
3786        return _pywrapcp.RevInteger_Value(self)
3787
3788    def SetValue(self, s, val):
3789        return _pywrapcp.RevInteger_SetValue(self, s, val)
3790    __swig_destroy__ = _pywrapcp.delete_RevInteger

This class adds reversibility to a POD type. It contains the stamp optimization. i.e. the SaveValue call is done only once per node of the search tree. Please note that actual stamps always starts at 1, thus an initial value of 0 will always trigger the first SaveValue.

RevInteger(val)
3782    def __init__(self, val):
3783        _pywrapcp.RevInteger_swiginit(self, _pywrapcp.new_RevInteger(val))
thisown

The membership flag

def Value(self):
3785    def Value(self):
3786        return _pywrapcp.RevInteger_Value(self)
def SetValue(self, s, val):
3788    def SetValue(self, s, val):
3789        return _pywrapcp.RevInteger_SetValue(self, s, val)
class NumericalRevInteger(RevInteger):
3794class NumericalRevInteger(RevInteger):
3795    r""" Subclass of Rev<T> which adds numerical operations."""
3796
3797    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3798    __repr__ = _swig_repr
3799
3800    def __init__(self, val):
3801        _pywrapcp.NumericalRevInteger_swiginit(self, _pywrapcp.new_NumericalRevInteger(val))
3802
3803    def Add(self, s, to_add):
3804        return _pywrapcp.NumericalRevInteger_Add(self, s, to_add)
3805
3806    def Incr(self, s):
3807        return _pywrapcp.NumericalRevInteger_Incr(self, s)
3808
3809    def Decr(self, s):
3810        return _pywrapcp.NumericalRevInteger_Decr(self, s)
3811    __swig_destroy__ = _pywrapcp.delete_NumericalRevInteger

Subclass of Rev which adds numerical operations.

NumericalRevInteger(val)
3800    def __init__(self, val):
3801        _pywrapcp.NumericalRevInteger_swiginit(self, _pywrapcp.new_NumericalRevInteger(val))
thisown

The membership flag

def Add(self, s, to_add):
3803    def Add(self, s, to_add):
3804        return _pywrapcp.NumericalRevInteger_Add(self, s, to_add)
def Incr(self, s):
3806    def Incr(self, s):
3807        return _pywrapcp.NumericalRevInteger_Incr(self, s)
def Decr(self, s):
3809    def Decr(self, s):
3810        return _pywrapcp.NumericalRevInteger_Decr(self, s)
Inherited Members
RevInteger
Value
SetValue
class RevBool:
3815class RevBool(object):
3816    r"""
3817    This class adds reversibility to a POD type.
3818    It contains the stamp optimization. i.e. the SaveValue call is done
3819    only once per node of the search tree.  Please note that actual
3820    stamps always starts at 1, thus an initial value of 0 will always
3821    trigger the first SaveValue.
3822    """
3823
3824    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3825    __repr__ = _swig_repr
3826
3827    def __init__(self, val):
3828        _pywrapcp.RevBool_swiginit(self, _pywrapcp.new_RevBool(val))
3829
3830    def Value(self):
3831        return _pywrapcp.RevBool_Value(self)
3832
3833    def SetValue(self, s, val):
3834        return _pywrapcp.RevBool_SetValue(self, s, val)
3835    __swig_destroy__ = _pywrapcp.delete_RevBool

This class adds reversibility to a POD type. It contains the stamp optimization. i.e. the SaveValue call is done only once per node of the search tree. Please note that actual stamps always starts at 1, thus an initial value of 0 will always trigger the first SaveValue.

RevBool(val)
3827    def __init__(self, val):
3828        _pywrapcp.RevBool_swiginit(self, _pywrapcp.new_RevBool(val))
thisown

The membership flag

def Value(self):
3830    def Value(self):
3831        return _pywrapcp.RevBool_Value(self)
def SetValue(self, s, val):
3833    def SetValue(self, s, val):
3834        return _pywrapcp.RevBool_SetValue(self, s, val)
class IntVarContainer:
3839class IntVarContainer(object):
3840    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3841
3842    def __init__(self, *args, **kwargs):
3843        raise AttributeError("No constructor defined")
3844    __repr__ = _swig_repr
3845
3846    def Contains(self, var):
3847        return _pywrapcp.IntVarContainer_Contains(self, var)
3848
3849    def Element(self, index):
3850        return _pywrapcp.IntVarContainer_Element(self, index)
3851
3852    def Size(self):
3853        return _pywrapcp.IntVarContainer_Size(self)
3854
3855    def Store(self):
3856        return _pywrapcp.IntVarContainer_Store(self)
3857
3858    def Restore(self):
3859        return _pywrapcp.IntVarContainer_Restore(self)
3860
3861    def __eq__(self, container):
3862        r"""
3863        Returns true if this and 'container' both represent the same V* -> E map.
3864        Runs in linear time; requires that the == operator on the type E is well
3865        defined.
3866        """
3867        return _pywrapcp.IntVarContainer___eq__(self, container)
3868
3869    def __ne__(self, container):
3870        return _pywrapcp.IntVarContainer___ne__(self, container)
3871    __swig_destroy__ = _pywrapcp.delete_IntVarContainer
IntVarContainer(*args, **kwargs)
3842    def __init__(self, *args, **kwargs):
3843        raise AttributeError("No constructor defined")
thisown

The membership flag

def Contains(self, var):
3846    def Contains(self, var):
3847        return _pywrapcp.IntVarContainer_Contains(self, var)
def Element(self, index):
3849    def Element(self, index):
3850        return _pywrapcp.IntVarContainer_Element(self, index)
def Size(self):
3852    def Size(self):
3853        return _pywrapcp.IntVarContainer_Size(self)
def Store(self):
3855    def Store(self):
3856        return _pywrapcp.IntVarContainer_Store(self)
def Restore(self):
3858    def Restore(self):
3859        return _pywrapcp.IntVarContainer_Restore(self)
class IntervalVarContainer:
3875class IntervalVarContainer(object):
3876    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3877
3878    def __init__(self, *args, **kwargs):
3879        raise AttributeError("No constructor defined")
3880    __repr__ = _swig_repr
3881
3882    def Contains(self, var):
3883        return _pywrapcp.IntervalVarContainer_Contains(self, var)
3884
3885    def Element(self, index):
3886        return _pywrapcp.IntervalVarContainer_Element(self, index)
3887
3888    def Size(self):
3889        return _pywrapcp.IntervalVarContainer_Size(self)
3890
3891    def Store(self):
3892        return _pywrapcp.IntervalVarContainer_Store(self)
3893
3894    def Restore(self):
3895        return _pywrapcp.IntervalVarContainer_Restore(self)
3896
3897    def __eq__(self, container):
3898        r"""
3899        Returns true if this and 'container' both represent the same V* -> E map.
3900        Runs in linear time; requires that the == operator on the type E is well
3901        defined.
3902        """
3903        return _pywrapcp.IntervalVarContainer___eq__(self, container)
3904
3905    def __ne__(self, container):
3906        return _pywrapcp.IntervalVarContainer___ne__(self, container)
3907    __swig_destroy__ = _pywrapcp.delete_IntervalVarContainer
IntervalVarContainer(*args, **kwargs)
3878    def __init__(self, *args, **kwargs):
3879        raise AttributeError("No constructor defined")
thisown

The membership flag

def Contains(self, var):
3882    def Contains(self, var):
3883        return _pywrapcp.IntervalVarContainer_Contains(self, var)
def Element(self, index):
3885    def Element(self, index):
3886        return _pywrapcp.IntervalVarContainer_Element(self, index)
def Size(self):
3888    def Size(self):
3889        return _pywrapcp.IntervalVarContainer_Size(self)
def Store(self):
3891    def Store(self):
3892        return _pywrapcp.IntervalVarContainer_Store(self)
def Restore(self):
3894    def Restore(self):
3895        return _pywrapcp.IntervalVarContainer_Restore(self)
class SequenceVarContainer:
3911class SequenceVarContainer(object):
3912    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3913
3914    def __init__(self, *args, **kwargs):
3915        raise AttributeError("No constructor defined")
3916    __repr__ = _swig_repr
3917
3918    def Contains(self, var):
3919        return _pywrapcp.SequenceVarContainer_Contains(self, var)
3920
3921    def Element(self, index):
3922        return _pywrapcp.SequenceVarContainer_Element(self, index)
3923
3924    def Size(self):
3925        return _pywrapcp.SequenceVarContainer_Size(self)
3926
3927    def Store(self):
3928        return _pywrapcp.SequenceVarContainer_Store(self)
3929
3930    def Restore(self):
3931        return _pywrapcp.SequenceVarContainer_Restore(self)
3932
3933    def __eq__(self, container):
3934        r"""
3935        Returns true if this and 'container' both represent the same V* -> E map.
3936        Runs in linear time; requires that the == operator on the type E is well
3937        defined.
3938        """
3939        return _pywrapcp.SequenceVarContainer___eq__(self, container)
3940
3941    def __ne__(self, container):
3942        return _pywrapcp.SequenceVarContainer___ne__(self, container)
3943    __swig_destroy__ = _pywrapcp.delete_SequenceVarContainer
SequenceVarContainer(*args, **kwargs)
3914    def __init__(self, *args, **kwargs):
3915        raise AttributeError("No constructor defined")
thisown

The membership flag

def Contains(self, var):
3918    def Contains(self, var):
3919        return _pywrapcp.SequenceVarContainer_Contains(self, var)
def Element(self, index):
3921    def Element(self, index):
3922        return _pywrapcp.SequenceVarContainer_Element(self, index)
def Size(self):
3924    def Size(self):
3925        return _pywrapcp.SequenceVarContainer_Size(self)
def Store(self):
3927    def Store(self):
3928        return _pywrapcp.SequenceVarContainer_Store(self)
def Restore(self):
3930    def Restore(self):
3931        return _pywrapcp.SequenceVarContainer_Restore(self)
class LocalSearchOperator(BaseObject):
3947class LocalSearchOperator(BaseObject):
3948    r"""
3949    The base class for all local search operators.
3950
3951    A local search operator is an object that defines the neighborhood of a
3952    solution. In other words, a neighborhood is the set of solutions which can
3953    be reached from a given solution using an operator.
3954
3955    The behavior of the LocalSearchOperator class is similar to iterators.
3956    The operator is synchronized with an assignment (gives the
3957    current values of the variables); this is done in the Start() method.
3958
3959    Then one can iterate over the neighbors using the MakeNextNeighbor method.
3960    This method returns an assignment which represents the incremental changes
3961    to the current solution. It also returns a second assignment representing
3962    the changes to the last solution defined by the neighborhood operator; this
3963    assignment is empty if the neighborhood operator cannot track this
3964    information.
3965    """
3966
3967    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3968
3969    def __init__(self, *args, **kwargs):
3970        raise AttributeError("No constructor defined - class is abstract")
3971    __repr__ = _swig_repr
3972
3973    def NextNeighbor(self, delta, deltadelta):
3974        return _pywrapcp.LocalSearchOperator_NextNeighbor(self, delta, deltadelta)
3975
3976    def Start(self, assignment):
3977        return _pywrapcp.LocalSearchOperator_Start(self, assignment)
3978    def __disown__(self):
3979        self.this.disown()
3980        _pywrapcp.disown_LocalSearchOperator(self)
3981        return weakref.proxy(self)

The base class for all local search operators.

A local search operator is an object that defines the neighborhood of a solution. In other words, a neighborhood is the set of solutions which can be reached from a given solution using an operator.

The behavior of the LocalSearchOperator class is similar to iterators. The operator is synchronized with an assignment (gives the current values of the variables); this is done in the Start() method.

Then one can iterate over the neighbors using the MakeNextNeighbor method. This method returns an assignment which represents the incremental changes to the current solution. It also returns a second assignment representing the changes to the last solution defined by the neighborhood operator; this assignment is empty if the neighborhood operator cannot track this information.

LocalSearchOperator(*args, **kwargs)
3969    def __init__(self, *args, **kwargs):
3970        raise AttributeError("No constructor defined - class is abstract")
thisown

The membership flag

def NextNeighbor(self, delta, deltadelta):
3973    def NextNeighbor(self, delta, deltadelta):
3974        return _pywrapcp.LocalSearchOperator_NextNeighbor(self, delta, deltadelta)
def Start(self, assignment):
3976    def Start(self, assignment):
3977        return _pywrapcp.LocalSearchOperator_Start(self, assignment)
Inherited Members
BaseObject
DebugString
class IntVarLocalSearchOperator(LocalSearchOperator):
3985class IntVarLocalSearchOperator(LocalSearchOperator):
3986    r"""
3987    Specialization of LocalSearchOperator built from an array of IntVars
3988    which specifies the scope of the operator.
3989    This class also takes care of storing current variable values in Start(),
3990    keeps track of changes done by the operator and builds the delta.
3991    The Deactivate() method can be used to perform Large Neighborhood Search.
3992    """
3993
3994    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3995    __repr__ = _swig_repr
3996
3997    def __init__(self, vars, keep_inverse_values=False):
3998        if self.__class__ == IntVarLocalSearchOperator:
3999            _self = None
4000        else:
4001            _self = self
4002        _pywrapcp.IntVarLocalSearchOperator_swiginit(self, _pywrapcp.new_IntVarLocalSearchOperator(_self, vars, keep_inverse_values))
4003    __swig_destroy__ = _pywrapcp.delete_IntVarLocalSearchOperator
4004
4005    def Start(self, assignment):
4006        r"""
4007        This method should not be overridden. Override OnStart() instead which is
4008        called before exiting this method.
4009        """
4010        return _pywrapcp.IntVarLocalSearchOperator_Start(self, assignment)
4011
4012    def IsIncremental(self):
4013        return _pywrapcp.IntVarLocalSearchOperator_IsIncremental(self)
4014
4015    def Size(self):
4016        return _pywrapcp.IntVarLocalSearchOperator_Size(self)
4017
4018    def Value(self, index):
4019        r"""
4020        Returns the value in the current assignment of the variable of given
4021        index.
4022        """
4023        return _pywrapcp.IntVarLocalSearchOperator_Value(self, index)
4024
4025    def Var(self, index):
4026        r""" Returns the variable of given index."""
4027        return _pywrapcp.IntVarLocalSearchOperator_Var(self, index)
4028
4029    def OldValue(self, index):
4030        return _pywrapcp.IntVarLocalSearchOperator_OldValue(self, index)
4031
4032    def PrevValue(self, index):
4033        return _pywrapcp.IntVarLocalSearchOperator_PrevValue(self, index)
4034
4035    def SetValue(self, index, value):
4036        return _pywrapcp.IntVarLocalSearchOperator_SetValue(self, index, value)
4037
4038    def Activated(self, index):
4039        return _pywrapcp.IntVarLocalSearchOperator_Activated(self, index)
4040
4041    def Activate(self, index):
4042        return _pywrapcp.IntVarLocalSearchOperator_Activate(self, index)
4043
4044    def Deactivate(self, index):
4045        return _pywrapcp.IntVarLocalSearchOperator_Deactivate(self, index)
4046
4047    def AddVars(self, vars):
4048        return _pywrapcp.IntVarLocalSearchOperator_AddVars(self, vars)
4049
4050    def OnStart(self):
4051        r"""
4052        Called by Start() after synchronizing the operator with the current
4053        assignment. Should be overridden instead of Start() to avoid calling
4054        IntVarLocalSearchOperator::Start explicitly.
4055        """
4056        return _pywrapcp.IntVarLocalSearchOperator_OnStart(self)
4057
4058    def NextNeighbor(self, delta, deltadelta):
4059        r"""
4060        OnStart() should really be protected, but then SWIG doesn't see it. So we
4061        make it public, but only subclasses should access to it (to override it).
4062        Redefines MakeNextNeighbor to export a simpler interface. The calls to
4063        ApplyChanges() and RevertChanges() are factored in this method, hiding
4064        both delta and deltadelta from subclasses which only need to override
4065        MakeOneNeighbor().
4066        Therefore this method should not be overridden. Override MakeOneNeighbor()
4067        instead.
4068        """
4069        return _pywrapcp.IntVarLocalSearchOperator_NextNeighbor(self, delta, deltadelta)
4070
4071    def OneNeighbor(self):
4072        r"""
4073        Creates a new neighbor. It returns false when the neighborhood is
4074        completely explored.
4075        MakeNextNeighbor() in a subclass of IntVarLocalSearchOperator.
4076        """
4077        return _pywrapcp.IntVarLocalSearchOperator_OneNeighbor(self)
4078    def __disown__(self):
4079        self.this.disown()
4080        _pywrapcp.disown_IntVarLocalSearchOperator(self)
4081        return weakref.proxy(self)

Specialization of LocalSearchOperator built from an array of IntVars which specifies the scope of the operator. This class also takes care of storing current variable values in Start(), keeps track of changes done by the operator and builds the delta. The Deactivate() method can be used to perform Large Neighborhood Search.

IntVarLocalSearchOperator(vars, keep_inverse_values=False)
3997    def __init__(self, vars, keep_inverse_values=False):
3998        if self.__class__ == IntVarLocalSearchOperator:
3999            _self = None
4000        else:
4001            _self = self
4002        _pywrapcp.IntVarLocalSearchOperator_swiginit(self, _pywrapcp.new_IntVarLocalSearchOperator(_self, vars, keep_inverse_values))
thisown

The membership flag

def Start(self, assignment):
4005    def Start(self, assignment):
4006        r"""
4007        This method should not be overridden. Override OnStart() instead which is
4008        called before exiting this method.
4009        """
4010        return _pywrapcp.IntVarLocalSearchOperator_Start(self, assignment)

This method should not be overridden. Override OnStart() instead which is called before exiting this method.

def IsIncremental(self):
4012    def IsIncremental(self):
4013        return _pywrapcp.IntVarLocalSearchOperator_IsIncremental(self)
def Size(self):
4015    def Size(self):
4016        return _pywrapcp.IntVarLocalSearchOperator_Size(self)
def Value(self, index):
4018    def Value(self, index):
4019        r"""
4020        Returns the value in the current assignment of the variable of given
4021        index.
4022        """
4023        return _pywrapcp.IntVarLocalSearchOperator_Value(self, index)

Returns the value in the current assignment of the variable of given index.

def Var(self, index):
4025    def Var(self, index):
4026        r""" Returns the variable of given index."""
4027        return _pywrapcp.IntVarLocalSearchOperator_Var(self, index)

Returns the variable of given index.

def OldValue(self, index):
4029    def OldValue(self, index):
4030        return _pywrapcp.IntVarLocalSearchOperator_OldValue(self, index)
def PrevValue(self, index):
4032    def PrevValue(self, index):
4033        return _pywrapcp.IntVarLocalSearchOperator_PrevValue(self, index)
def SetValue(self, index, value):
4035    def SetValue(self, index, value):
4036        return _pywrapcp.IntVarLocalSearchOperator_SetValue(self, index, value)
def Activated(self, index):
4038    def Activated(self, index):
4039        return _pywrapcp.IntVarLocalSearchOperator_Activated(self, index)
def Activate(self, index):
4041    def Activate(self, index):
4042        return _pywrapcp.IntVarLocalSearchOperator_Activate(self, index)
def Deactivate(self, index):
4044    def Deactivate(self, index):
4045        return _pywrapcp.IntVarLocalSearchOperator_Deactivate(self, index)
def AddVars(self, vars):
4047    def AddVars(self, vars):
4048        return _pywrapcp.IntVarLocalSearchOperator_AddVars(self, vars)
def OnStart(self):
4050    def OnStart(self):
4051        r"""
4052        Called by Start() after synchronizing the operator with the current
4053        assignment. Should be overridden instead of Start() to avoid calling
4054        IntVarLocalSearchOperator::Start explicitly.
4055        """
4056        return _pywrapcp.IntVarLocalSearchOperator_OnStart(self)

Called by Start() after synchronizing the operator with the current assignment. Should be overridden instead of Start() to avoid calling IntVarLocalSearchOperator::Start explicitly.

def NextNeighbor(self, delta, deltadelta):
4058    def NextNeighbor(self, delta, deltadelta):
4059        r"""
4060        OnStart() should really be protected, but then SWIG doesn't see it. So we
4061        make it public, but only subclasses should access to it (to override it).
4062        Redefines MakeNextNeighbor to export a simpler interface. The calls to
4063        ApplyChanges() and RevertChanges() are factored in this method, hiding
4064        both delta and deltadelta from subclasses which only need to override
4065        MakeOneNeighbor().
4066        Therefore this method should not be overridden. Override MakeOneNeighbor()
4067        instead.
4068        """
4069        return _pywrapcp.IntVarLocalSearchOperator_NextNeighbor(self, delta, deltadelta)

OnStart() should really be protected, but then SWIG doesn't see it. So we make it public, but only subclasses should access to it (to override it). Redefines MakeNextNeighbor to export a simpler interface. The calls to ApplyChanges() and RevertChanges() are factored in this method, hiding both delta and deltadelta from subclasses which only need to override MakeOneNeighbor(). Therefore this method should not be overridden. Override MakeOneNeighbor() instead.

def OneNeighbor(self):
4071    def OneNeighbor(self):
4072        r"""
4073        Creates a new neighbor. It returns false when the neighborhood is
4074        completely explored.
4075        MakeNextNeighbor() in a subclass of IntVarLocalSearchOperator.
4076        """
4077        return _pywrapcp.IntVarLocalSearchOperator_OneNeighbor(self)

Creates a new neighbor. It returns false when the neighborhood is completely explored. MakeNextNeighbor() in a subclass of IntVarLocalSearchOperator.

Inherited Members
BaseObject
DebugString
class BaseLns(IntVarLocalSearchOperator):
4085class BaseLns(IntVarLocalSearchOperator):
4086    r"""
4087    This is the base class for building an Lns operator. An Lns fragment is a
4088    collection of variables which will be relaxed. Fragments are built with
4089    NextFragment(), which returns false if there are no more fragments to build.
4090    Optionally one can override InitFragments, which is called from
4091    LocalSearchOperator::Start to initialize fragment data.
4092
4093    Here's a sample relaxing one variable at a time:
4094
4095    class OneVarLns : public BaseLns {
4096     public:
4097      OneVarLns(const std::vector<IntVar*>& vars) : BaseLns(vars), index_(0) {}
4098      virtual ~OneVarLns() {}
4099      virtual void InitFragments() { index_ = 0; }
4100      virtual bool NextFragment() {
4101        const int size = Size();
4102        if (index_ < size) {
4103          AppendToFragment(index_);
4104          ++index_;
4105          return true;
4106        } else {
4107          return false;
4108        }
4109      }
4110
4111     private:
4112      int index_;
4113    };
4114    """
4115
4116    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4117    __repr__ = _swig_repr
4118
4119    def __init__(self, vars):
4120        if self.__class__ == BaseLns:
4121            _self = None
4122        else:
4123            _self = self
4124        _pywrapcp.BaseLns_swiginit(self, _pywrapcp.new_BaseLns(_self, vars))
4125    __swig_destroy__ = _pywrapcp.delete_BaseLns
4126
4127    def InitFragments(self):
4128        return _pywrapcp.BaseLns_InitFragments(self)
4129
4130    def NextFragment(self):
4131        return _pywrapcp.BaseLns_NextFragment(self)
4132
4133    def AppendToFragment(self, index):
4134        return _pywrapcp.BaseLns_AppendToFragment(self, index)
4135
4136    def FragmentSize(self):
4137        return _pywrapcp.BaseLns_FragmentSize(self)
4138
4139    def __getitem__(self, index):
4140        return _pywrapcp.BaseLns___getitem__(self, index)
4141
4142    def __len__(self):
4143        return _pywrapcp.BaseLns___len__(self)
4144    def __disown__(self):
4145        self.this.disown()
4146        _pywrapcp.disown_BaseLns(self)
4147        return weakref.proxy(self)

This is the base class for building an Lns operator. An Lns fragment is a collection of variables which will be relaxed. Fragments are built with NextFragment(), which returns false if there are no more fragments to build. Optionally one can override InitFragments, which is called from LocalSearchOperator::Start to initialize fragment data.

Here's a sample relaxing one variable at a time:

class OneVarLns : public BaseLns { public: OneVarLns(const std::vector& vars) : BaseLns(vars), index_(0) {} virtual ~OneVarLns() {} virtual void InitFragments() { index_ = 0; } virtual bool NextFragment() { const int size = Size(); if (index_ < size) { AppendToFragment(index_); ++index_; return true; } else { return false; } }

private: int index_; };

BaseLns(vars)
4119    def __init__(self, vars):
4120        if self.__class__ == BaseLns:
4121            _self = None
4122        else:
4123            _self = self
4124        _pywrapcp.BaseLns_swiginit(self, _pywrapcp.new_BaseLns(_self, vars))
thisown

The membership flag

def InitFragments(self):
4127    def InitFragments(self):
4128        return _pywrapcp.BaseLns_InitFragments(self)
def NextFragment(self):
4130    def NextFragment(self):
4131        return _pywrapcp.BaseLns_NextFragment(self)
def AppendToFragment(self, index):
4133    def AppendToFragment(self, index):
4134        return _pywrapcp.BaseLns_AppendToFragment(self, index)
def FragmentSize(self):
4136    def FragmentSize(self):
4137        return _pywrapcp.BaseLns_FragmentSize(self)
class ChangeValue(IntVarLocalSearchOperator):
4151class ChangeValue(IntVarLocalSearchOperator):
4152    r"""
4153    Defines operators which change the value of variables;
4154    each neighbor corresponds to *one* modified variable.
4155    Sub-classes have to define ModifyValue which determines what the new
4156    variable value is going to be (given the current value and the variable).
4157    """
4158
4159    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4160    __repr__ = _swig_repr
4161
4162    def __init__(self, vars):
4163        if self.__class__ == ChangeValue:
4164            _self = None
4165        else:
4166            _self = self
4167        _pywrapcp.ChangeValue_swiginit(self, _pywrapcp.new_ChangeValue(_self, vars))
4168    __swig_destroy__ = _pywrapcp.delete_ChangeValue
4169
4170    def ModifyValue(self, index, value):
4171        return _pywrapcp.ChangeValue_ModifyValue(self, index, value)
4172
4173    def OneNeighbor(self):
4174        r""" This method should not be overridden. Override ModifyValue() instead."""
4175        return _pywrapcp.ChangeValue_OneNeighbor(self)
4176    def __disown__(self):
4177        self.this.disown()
4178        _pywrapcp.disown_ChangeValue(self)
4179        return weakref.proxy(self)

Defines operators which change the value of variables; each neighbor corresponds to one modified variable. Sub-classes have to define ModifyValue which determines what the new variable value is going to be (given the current value and the variable).

ChangeValue(vars)
4162    def __init__(self, vars):
4163        if self.__class__ == ChangeValue:
4164            _self = None
4165        else:
4166            _self = self
4167        _pywrapcp.ChangeValue_swiginit(self, _pywrapcp.new_ChangeValue(_self, vars))
thisown

The membership flag

def ModifyValue(self, index, value):
4170    def ModifyValue(self, index, value):
4171        return _pywrapcp.ChangeValue_ModifyValue(self, index, value)
def OneNeighbor(self):
4173    def OneNeighbor(self):
4174        r""" This method should not be overridden. Override ModifyValue() instead."""
4175        return _pywrapcp.ChangeValue_OneNeighbor(self)

This method should not be overridden. Override ModifyValue() instead.

class PathOperator(IntVarLocalSearchOperator):
4183class PathOperator(IntVarLocalSearchOperator):
4184    r"""
4185    Base class of the local search operators dedicated to path modifications
4186    (a path is a set of nodes linked together by arcs).
4187    This family of neighborhoods supposes they are handling next variables
4188    representing the arcs (var[i] represents the node immediately after i on
4189    a path).
4190    Several services are provided:
4191    - arc manipulators (SetNext(), ReverseChain(), MoveChain())
4192    - path inspectors (Next(), Prev(), IsPathEnd())
4193    - path iterators: operators need a given number of nodes to define a
4194      neighbor; this class provides the iteration on a given number of (base)
4195      nodes which can be used to define a neighbor (through the BaseNode method)
4196    Subclasses only need to override MakeNeighbor to create neighbors using
4197    the services above (no direct manipulation of assignments).
4198    """
4199
4200    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4201
4202    def __init__(self, *args, **kwargs):
4203        raise AttributeError("No constructor defined - class is abstract")
4204    __repr__ = _swig_repr
4205
4206    def Neighbor(self):
4207        return _pywrapcp.PathOperator_Neighbor(self)

Base class of the local search operators dedicated to path modifications (a path is a set of nodes linked together by arcs). This family of neighborhoods supposes they are handling next variables representing the arcs (var[i] represents the node immediately after i on a path). Several services are provided:

  • arc manipulators (SetNext(), ReverseChain(), MoveChain())
  • path inspectors (Next(), Prev(), IsPathEnd())
  • path iterators: operators need a given number of nodes to define a neighbor; this class provides the iteration on a given number of (base) nodes which can be used to define a neighbor (through the BaseNode method) Subclasses only need to override MakeNeighbor to create neighbors using the services above (no direct manipulation of assignments).
PathOperator(*args, **kwargs)
4202    def __init__(self, *args, **kwargs):
4203        raise AttributeError("No constructor defined - class is abstract")
thisown

The membership flag

def Neighbor(self):
4206    def Neighbor(self):
4207        return _pywrapcp.PathOperator_Neighbor(self)
class LocalSearchFilter(BaseObject):
4211class LocalSearchFilter(BaseObject):
4212    r"""
4213    Classes to which this template function can be applied to as of 04/2014.
4214    Usage: LocalSearchOperator* op = MakeLocalSearchOperator<Relocate>(...);
4215    class TwoOpt;
4216    class Relocate;
4217    class Exchange;
4218    class Cross;
4219    class MakeActiveOperator;
4220    class MakeInactiveOperator;
4221    class MakeChainInactiveOperator;
4222    class SwapActiveOperator;
4223    class ExtendedSwapActiveOperator;
4224    class MakeActiveAndRelocate;
4225    class RelocateAndMakeActiveOperator;
4226    class RelocateAndMakeInactiveOperator;
4227    Local Search Filters are used for fast neighbor pruning.
4228    Filtering a move is done in several phases:
4229    - in the Relax phase, filters determine which parts of their internals
4230      will be changed by the candidate, and modify intermediary State
4231    - in the Accept phase, filters check that the candidate is feasible,
4232    - if the Accept phase succeeds, the solver may decide to trigger a
4233      Synchronize phase that makes filters change their internal representation
4234      to the last candidate,
4235    - otherwise (Accept fails or the solver does not want to synchronize),
4236      a Revert phase makes filters erase any intermediary State generated by the
4237      Relax and Accept phases.
4238    A given filter has phases called with the following pattern:
4239    (Relax.Accept.Synchronize | Relax.Accept.Revert | Relax.Revert)*.
4240    Filters's Revert() is always called in the reverse order their Accept() was
4241    called, to allow late filters to use state done/undone by early filters'
4242    Accept()/Revert().
4243    """
4244
4245    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4246
4247    def __init__(self, *args, **kwargs):
4248        raise AttributeError("No constructor defined - class is abstract")
4249    __repr__ = _swig_repr
4250
4251    def Accept(self, delta, deltadelta, objective_min, objective_max):
4252        r"""
4253        Accepts a "delta" given the assignment with which the filter has been
4254        synchronized; the delta holds the variables which have been modified and
4255        their new value.
4256        If the filter represents a part of the global objective, its contribution
4257        must be between objective_min and objective_max.
4258        Sample: supposing one wants to maintain a[0,1] + b[0,1] <= 1,
4259        for the assignment (a,1), (b,0), the delta (b,1) will be rejected
4260        but the delta (a,0) will be accepted.
4261        TODO(user): Remove arguments when there are no more need for those.
4262        """
4263        return _pywrapcp.LocalSearchFilter_Accept(self, delta, deltadelta, objective_min, objective_max)
4264
4265    def IsIncremental(self):
4266        return _pywrapcp.LocalSearchFilter_IsIncremental(self)
4267
4268    def Synchronize(self, assignment, delta):
4269        r"""
4270        Synchronizes the filter with the current solution, delta being the
4271        difference with the solution passed to the previous call to Synchronize()
4272        or IncrementalSynchronize(). 'delta' can be used to incrementally
4273        synchronizing the filter with the new solution by only considering the
4274        changes in delta.
4275        """
4276        return _pywrapcp.LocalSearchFilter_Synchronize(self, assignment, delta)
4277    __swig_destroy__ = _pywrapcp.delete_LocalSearchFilter

Classes to which this template function can be applied to as of 04/2014. Usage: LocalSearchOperator* op = MakeLocalSearchOperator(...); class TwoOpt; class Relocate; class Exchange; class Cross; class MakeActiveOperator; class MakeInactiveOperator; class MakeChainInactiveOperator; class SwapActiveOperator; class ExtendedSwapActiveOperator; class MakeActiveAndRelocate; class RelocateAndMakeActiveOperator; class RelocateAndMakeInactiveOperator; Local Search Filters are used for fast neighbor pruning. Filtering a move is done in several phases:

  • in the Relax phase, filters determine which parts of their internals will be changed by the candidate, and modify intermediary State
  • in the Accept phase, filters check that the candidate is feasible,
  • if the Accept phase succeeds, the solver may decide to trigger a Synchronize phase that makes filters change their internal representation to the last candidate,
  • otherwise (Accept fails or the solver does not want to synchronize), a Revert phase makes filters erase any intermediary State generated by the Relax and Accept phases. A given filter has phases called with the following pattern: (Relax.Accept.Synchronize | Relax.Accept.Revert | Relax.Revert)*. Filters's Revert() is always called in the reverse order their Accept() was called, to allow late filters to use state done/undone by early filters' Accept()/Revert().
LocalSearchFilter(*args, **kwargs)
4247    def __init__(self, *args, **kwargs):
4248        raise AttributeError("No constructor defined - class is abstract")
thisown

The membership flag

def Accept(self, delta, deltadelta, objective_min, objective_max):
4251    def Accept(self, delta, deltadelta, objective_min, objective_max):
4252        r"""
4253        Accepts a "delta" given the assignment with which the filter has been
4254        synchronized; the delta holds the variables which have been modified and
4255        their new value.
4256        If the filter represents a part of the global objective, its contribution
4257        must be between objective_min and objective_max.
4258        Sample: supposing one wants to maintain a[0,1] + b[0,1] <= 1,
4259        for the assignment (a,1), (b,0), the delta (b,1) will be rejected
4260        but the delta (a,0) will be accepted.
4261        TODO(user): Remove arguments when there are no more need for those.
4262        """
4263        return _pywrapcp.LocalSearchFilter_Accept(self, delta, deltadelta, objective_min, objective_max)

Accepts a "delta" given the assignment with which the filter has been synchronized; the delta holds the variables which have been modified and their new value. If the filter represents a part of the global objective, its contribution must be between objective_min and objective_max. Sample: supposing one wants to maintain a[0,1] + b[0,1] <= 1, for the assignment (a,1), (b,0), the delta (b,1) will be rejected but the delta (a,0) will be accepted. TODO(user): Remove arguments when there are no more need for those.

def IsIncremental(self):
4265    def IsIncremental(self):
4266        return _pywrapcp.LocalSearchFilter_IsIncremental(self)
def Synchronize(self, assignment, delta):
4268    def Synchronize(self, assignment, delta):
4269        r"""
4270        Synchronizes the filter with the current solution, delta being the
4271        difference with the solution passed to the previous call to Synchronize()
4272        or IncrementalSynchronize(). 'delta' can be used to incrementally
4273        synchronizing the filter with the new solution by only considering the
4274        changes in delta.
4275        """
4276        return _pywrapcp.LocalSearchFilter_Synchronize(self, assignment, delta)

Synchronizes the filter with the current solution, delta being the difference with the solution passed to the previous call to Synchronize() or IncrementalSynchronize(). 'delta' can be used to incrementally synchronizing the filter with the new solution by only considering the changes in delta.

Inherited Members
BaseObject
DebugString
class LocalSearchFilterManager(BaseObject):
4281class LocalSearchFilterManager(BaseObject):
4282    r"""
4283    Filter manager: when a move is made, filters are executed to decide whether
4284    the solution is feasible and compute parts of the new cost. This class
4285    schedules filter execution and composes costs as a sum.
4286    """
4287
4288    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4289    __repr__ = _swig_repr
4290
4291    def DebugString(self):
4292        return _pywrapcp.LocalSearchFilterManager_DebugString(self)
4293
4294    def __init__(self, *args):
4295        _pywrapcp.LocalSearchFilterManager_swiginit(self, _pywrapcp.new_LocalSearchFilterManager(*args))
4296
4297    def Accept(self, monitor, delta, deltadelta, objective_min, objective_max):
4298        r"""
4299        Returns true iff all filters return true, and the sum of their accepted
4300        objectives is between objective_min and objective_max.
4301        The monitor has its Begin/EndFiltering events triggered.
4302        """
4303        return _pywrapcp.LocalSearchFilterManager_Accept(self, monitor, delta, deltadelta, objective_min, objective_max)
4304
4305    def Synchronize(self, assignment, delta):
4306        r""" Synchronizes all filters to assignment."""
4307        return _pywrapcp.LocalSearchFilterManager_Synchronize(self, assignment, delta)
4308    __swig_destroy__ = _pywrapcp.delete_LocalSearchFilterManager

Filter manager: when a move is made, filters are executed to decide whether the solution is feasible and compute parts of the new cost. This class schedules filter execution and composes costs as a sum.

LocalSearchFilterManager(*args)
4294    def __init__(self, *args):
4295        _pywrapcp.LocalSearchFilterManager_swiginit(self, _pywrapcp.new_LocalSearchFilterManager(*args))
thisown

The membership flag

def DebugString(self):
4291    def DebugString(self):
4292        return _pywrapcp.LocalSearchFilterManager_DebugString(self)
def Accept(self, monitor, delta, deltadelta, objective_min, objective_max):
4297    def Accept(self, monitor, delta, deltadelta, objective_min, objective_max):
4298        r"""
4299        Returns true iff all filters return true, and the sum of their accepted
4300        objectives is between objective_min and objective_max.
4301        The monitor has its Begin/EndFiltering events triggered.
4302        """
4303        return _pywrapcp.LocalSearchFilterManager_Accept(self, monitor, delta, deltadelta, objective_min, objective_max)

Returns true iff all filters return true, and the sum of their accepted objectives is between objective_min and objective_max. The monitor has its Begin/EndFiltering events triggered.

def Synchronize(self, assignment, delta):
4305    def Synchronize(self, assignment, delta):
4306        r""" Synchronizes all filters to assignment."""
4307        return _pywrapcp.LocalSearchFilterManager_Synchronize(self, assignment, delta)

Synchronizes all filters to assignment.

class IntVarLocalSearchFilter(LocalSearchFilter):
4312class IntVarLocalSearchFilter(LocalSearchFilter):
4313    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4314    __repr__ = _swig_repr
4315
4316    def __init__(self, vars):
4317        if self.__class__ == IntVarLocalSearchFilter:
4318            _self = None
4319        else:
4320            _self = self
4321        _pywrapcp.IntVarLocalSearchFilter_swiginit(self, _pywrapcp.new_IntVarLocalSearchFilter(_self, vars))
4322    __swig_destroy__ = _pywrapcp.delete_IntVarLocalSearchFilter
4323
4324    def Synchronize(self, assignment, delta):
4325        r"""
4326        This method should not be overridden. Override OnSynchronize() instead
4327        which is called before exiting this method.
4328        """
4329        return _pywrapcp.IntVarLocalSearchFilter_Synchronize(self, assignment, delta)
4330
4331    def Size(self):
4332        return _pywrapcp.IntVarLocalSearchFilter_Size(self)
4333
4334    def Value(self, index):
4335        return _pywrapcp.IntVarLocalSearchFilter_Value(self, index)
4336
4337    def IndexFromVar(self, var):
4338        return _pywrapcp.IntVarLocalSearchFilter_IndexFromVar(self, var)
4339    def __disown__(self):
4340        self.this.disown()
4341        _pywrapcp.disown_IntVarLocalSearchFilter(self)
4342        return weakref.proxy(self)

Classes to which this template function can be applied to as of 04/2014. Usage: LocalSearchOperator* op = MakeLocalSearchOperator(...); class TwoOpt; class Relocate; class Exchange; class Cross; class MakeActiveOperator; class MakeInactiveOperator; class MakeChainInactiveOperator; class SwapActiveOperator; class ExtendedSwapActiveOperator; class MakeActiveAndRelocate; class RelocateAndMakeActiveOperator; class RelocateAndMakeInactiveOperator; Local Search Filters are used for fast neighbor pruning. Filtering a move is done in several phases:

  • in the Relax phase, filters determine which parts of their internals will be changed by the candidate, and modify intermediary State
  • in the Accept phase, filters check that the candidate is feasible,
  • if the Accept phase succeeds, the solver may decide to trigger a Synchronize phase that makes filters change their internal representation to the last candidate,
  • otherwise (Accept fails or the solver does not want to synchronize), a Revert phase makes filters erase any intermediary State generated by the Relax and Accept phases. A given filter has phases called with the following pattern: (Relax.Accept.Synchronize | Relax.Accept.Revert | Relax.Revert)*. Filters's Revert() is always called in the reverse order their Accept() was called, to allow late filters to use state done/undone by early filters' Accept()/Revert().
IntVarLocalSearchFilter(vars)
4316    def __init__(self, vars):
4317        if self.__class__ == IntVarLocalSearchFilter:
4318            _self = None
4319        else:
4320            _self = self
4321        _pywrapcp.IntVarLocalSearchFilter_swiginit(self, _pywrapcp.new_IntVarLocalSearchFilter(_self, vars))
thisown

The membership flag

def Synchronize(self, assignment, delta):
4324    def Synchronize(self, assignment, delta):
4325        r"""
4326        This method should not be overridden. Override OnSynchronize() instead
4327        which is called before exiting this method.
4328        """
4329        return _pywrapcp.IntVarLocalSearchFilter_Synchronize(self, assignment, delta)

This method should not be overridden. Override OnSynchronize() instead which is called before exiting this method.

def Size(self):
4331    def Size(self):
4332        return _pywrapcp.IntVarLocalSearchFilter_Size(self)
def Value(self, index):
4334    def Value(self, index):
4335        return _pywrapcp.IntVarLocalSearchFilter_Value(self, index)
def IndexFromVar(self, var):
4337    def IndexFromVar(self, var):
4338        return _pywrapcp.IntVarLocalSearchFilter_IndexFromVar(self, var)
class BooleanVar(IntVar):
4346class BooleanVar(IntVar):
4347    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4348
4349    def __init__(self, *args, **kwargs):
4350        raise AttributeError("No constructor defined - class is abstract")
4351    __repr__ = _swig_repr
4352
4353    def Min(self):
4354        return _pywrapcp.BooleanVar_Min(self)
4355
4356    def SetMin(self, m):
4357        return _pywrapcp.BooleanVar_SetMin(self, m)
4358
4359    def Max(self):
4360        return _pywrapcp.BooleanVar_Max(self)
4361
4362    def SetMax(self, m):
4363        return _pywrapcp.BooleanVar_SetMax(self, m)
4364
4365    def SetRange(self, mi, ma):
4366        return _pywrapcp.BooleanVar_SetRange(self, mi, ma)
4367
4368    def Bound(self):
4369        return _pywrapcp.BooleanVar_Bound(self)
4370
4371    def Value(self):
4372        return _pywrapcp.BooleanVar_Value(self)
4373
4374    def RemoveValue(self, v):
4375        return _pywrapcp.BooleanVar_RemoveValue(self, v)
4376
4377    def RemoveInterval(self, l, u):
4378        return _pywrapcp.BooleanVar_RemoveInterval(self, l, u)
4379
4380    def WhenBound(self, d):
4381        return _pywrapcp.BooleanVar_WhenBound(self, d)
4382
4383    def WhenRange(self, d):
4384        return _pywrapcp.BooleanVar_WhenRange(self, d)
4385
4386    def WhenDomain(self, d):
4387        return _pywrapcp.BooleanVar_WhenDomain(self, d)
4388
4389    def Size(self):
4390        return _pywrapcp.BooleanVar_Size(self)
4391
4392    def Contains(self, v):
4393        return _pywrapcp.BooleanVar_Contains(self, v)
4394
4395    def HoleIteratorAux(self, reversible):
4396        return _pywrapcp.BooleanVar_HoleIteratorAux(self, reversible)
4397
4398    def DomainIteratorAux(self, reversible):
4399        return _pywrapcp.BooleanVar_DomainIteratorAux(self, reversible)
4400
4401    def DebugString(self):
4402        return _pywrapcp.BooleanVar_DebugString(self)

The class IntVar is a subset of IntExpr. In addition to the IntExpr protocol, it offers persistence, removing values from the domains, and a finer model for events.

BooleanVar(*args, **kwargs)
4349    def __init__(self, *args, **kwargs):
4350        raise AttributeError("No constructor defined - class is abstract")
thisown

The membership flag

def Min(self):
4353    def Min(self):
4354        return _pywrapcp.BooleanVar_Min(self)
def SetMin(self, m):
4356    def SetMin(self, m):
4357        return _pywrapcp.BooleanVar_SetMin(self, m)
def Max(self):
4359    def Max(self):
4360        return _pywrapcp.BooleanVar_Max(self)
def SetMax(self, m):
4362    def SetMax(self, m):
4363        return _pywrapcp.BooleanVar_SetMax(self, m)
def SetRange(self, mi, ma):
4365    def SetRange(self, mi, ma):
4366        return _pywrapcp.BooleanVar_SetRange(self, mi, ma)

This method sets both the min and the max of the expression.

def Bound(self):
4368    def Bound(self):
4369        return _pywrapcp.BooleanVar_Bound(self)

Returns true if the min and the max of the expression are equal.

def Value(self):
4371    def Value(self):
4372        return _pywrapcp.BooleanVar_Value(self)

This method returns the value of the variable. This method checks before that the variable is bound.

def RemoveValue(self, v):
4374    def RemoveValue(self, v):
4375        return _pywrapcp.BooleanVar_RemoveValue(self, v)

This method removes the value 'v' from the domain of the variable.

def RemoveInterval(self, l, u):
4377    def RemoveInterval(self, l, u):
4378        return _pywrapcp.BooleanVar_RemoveInterval(self, l, u)

This method removes the interval 'l' .. 'u' from the domain of the variable. It assumes that 'l' <= 'u'.

def WhenBound(self, d):
4380    def WhenBound(self, d):
4381        return _pywrapcp.BooleanVar_WhenBound(self, d)

Overload 1: This method attaches a demon that will be awakened when the variable is bound.

|

Overload 2: This method attaches a closure that will be awakened when the variable is bound.

def WhenRange(self, d):
4383    def WhenRange(self, d):
4384        return _pywrapcp.BooleanVar_WhenRange(self, d)

Overload 1: Attach a demon that will watch the min or the max of the expression.

|

Overload 2: Attach a demon that will watch the min or the max of the expression.

def WhenDomain(self, d):
4386    def WhenDomain(self, d):
4387        return _pywrapcp.BooleanVar_WhenDomain(self, d)

Overload 1: This method attaches a demon that will watch any domain modification of the domain of the variable.

|

Overload 2: This method attaches a closure that will watch any domain modification of the domain of the variable.

def Size(self):
4389    def Size(self):
4390        return _pywrapcp.BooleanVar_Size(self)

This method returns the number of values in the domain of the variable.

def Contains(self, v):
4392    def Contains(self, v):
4393        return _pywrapcp.BooleanVar_Contains(self, v)

This method returns whether the value 'v' is in the domain of the variable.

def HoleIteratorAux(self, reversible):
4395    def HoleIteratorAux(self, reversible):
4396        return _pywrapcp.BooleanVar_HoleIteratorAux(self, reversible)

Creates a hole iterator. When 'reversible' is false, the returned object is created on the normal C++ heap and the solver does NOT take ownership of the object.

def DomainIteratorAux(self, reversible):
4398    def DomainIteratorAux(self, reversible):
4399        return _pywrapcp.BooleanVar_DomainIteratorAux(self, reversible)

Creates a domain iterator. When 'reversible' is false, the returned object is created on the normal C++ heap and the solver does NOT take ownership of the object.

def DebugString(self):
4401    def DebugString(self):
4402        return _pywrapcp.BooleanVar_DebugString(self)
class PyDecision(Decision):
4407class PyDecision(Decision):
4408
4409  def __init__(self):
4410    Decision.__init__(self)
4411
4412  def ApplyWrapper(self, solver):
4413    try:
4414       self.Apply(solver)
4415    except Exception as e:
4416      if 'CP Solver fail' in str(e):
4417        solver.ShouldFail()
4418      else:
4419        raise
4420
4421  def RefuteWrapper(self, solver):
4422    try:
4423       self.Refute(solver)
4424    except Exception as e:
4425      if 'CP Solver fail' in str(e):
4426        solver.ShouldFail()
4427      else:
4428        raise
4429
4430  def DebugString(self):
4431    return "PyDecision"

A Decision represents a choice point in the search tree. The two main methods are Apply() to go left, or Refute() to go right.

PyDecision()
4409  def __init__(self):
4410    Decision.__init__(self)
def ApplyWrapper(self, solver):
4412  def ApplyWrapper(self, solver):
4413    try:
4414       self.Apply(solver)
4415    except Exception as e:
4416      if 'CP Solver fail' in str(e):
4417        solver.ShouldFail()
4418      else:
4419        raise

Apply will be called first when the decision is executed.

def RefuteWrapper(self, solver):
4421  def RefuteWrapper(self, solver):
4422    try:
4423       self.Refute(solver)
4424    except Exception as e:
4425      if 'CP Solver fail' in str(e):
4426        solver.ShouldFail()
4427      else:
4428        raise

Refute will be called after a backtrack.

def DebugString(self):
4430  def DebugString(self):
4431    return "PyDecision"
Inherited Members
Decision
thisown
class PyDecisionBuilder(DecisionBuilder):
4434class PyDecisionBuilder(DecisionBuilder):
4435
4436  def __init__(self):
4437    DecisionBuilder.__init__(self)
4438
4439  def NextWrapper(self, solver):
4440    try:
4441      return self.Next(solver)
4442    except Exception as e:
4443      if 'CP Solver fail' in str(e):
4444        return solver.FailDecision()
4445      else:
4446        raise
4447
4448  def DebugString(self):
4449    return "PyDecisionBuilder"

A DecisionBuilder is responsible for creating the search tree. The important method is Next(), which returns the next decision to execute.

PyDecisionBuilder()
4436  def __init__(self):
4437    DecisionBuilder.__init__(self)
def NextWrapper(self, solver):
4439  def NextWrapper(self, solver):
4440    try:
4441      return self.Next(solver)
4442    except Exception as e:
4443      if 'CP Solver fail' in str(e):
4444        return solver.FailDecision()
4445      else:
4446        raise

This is the main method of the decision builder class. It must return a decision (an instance of the class Decision). If it returns nullptr, this means that the decision builder has finished its work.

def DebugString(self):
4448  def DebugString(self):
4449    return "PyDecisionBuilder"
Inherited Members
DecisionBuilder
thisown
class PyDemon(Demon):
4452class PyDemon(Demon):
4453
4454  def RunWrapper(self, solver):
4455    try:
4456      self.Run(solver)
4457    except Exception as e:
4458      if 'CP Solver fail' in str(e):
4459        solver.ShouldFail()
4460      else:
4461        raise
4462
4463  def DebugString(self):
4464    return "PyDemon"

A Demon is the base element of a propagation queue. It is the main object responsible for implementing the actual propagation of the constraint and pruning the inconsistent values in the domains of the variables. The main concept is that demons are listeners that are attached to the variables and listen to their modifications.

There are two methods:
  • Run() is the actual method called when the demon is processed.
  • priority() returns its priority. Standard priorities are slow, normal or fast. "immediate" is reserved for variables and is treated separately.
def RunWrapper(self, solver):
4454  def RunWrapper(self, solver):
4455    try:
4456      self.Run(solver)
4457    except Exception as e:
4458      if 'CP Solver fail' in str(e):
4459        solver.ShouldFail()
4460      else:
4461        raise

This is the main callback of the demon.

def DebugString(self):
4463  def DebugString(self):
4464    return "PyDemon"
class PyConstraintDemon(PyDemon):
4467class PyConstraintDemon(PyDemon):
4468
4469  def __init__(self, ct, method, delayed, *args):
4470    PyDemon.__init__(self)
4471    self.__constraint = ct
4472    self.__method = method
4473    self.__delayed = delayed
4474    self.__args = args
4475
4476  def Run(self, solver):
4477    self.__method(self.__constraint, *self.__args)
4478
4479  def Priority(self):
4480    return Solver.DELAYED_PRIORITY if self.__delayed else Solver.NORMAL_PRIORITY
4481
4482  def DebugString(self):
4483    return 'PyConstraintDemon'

A Demon is the base element of a propagation queue. It is the main object responsible for implementing the actual propagation of the constraint and pruning the inconsistent values in the domains of the variables. The main concept is that demons are listeners that are attached to the variables and listen to their modifications.

There are two methods:
  • Run() is the actual method called when the demon is processed.
  • priority() returns its priority. Standard priorities are slow, normal or fast. "immediate" is reserved for variables and is treated separately.
PyConstraintDemon(ct, method, delayed, *args)
4469  def __init__(self, ct, method, delayed, *args):
4470    PyDemon.__init__(self)
4471    self.__constraint = ct
4472    self.__method = method
4473    self.__delayed = delayed
4474    self.__args = args

This indicates the priority of a demon. Immediate demons are treated separately and corresponds to variables.

def Run(self, solver):
4476  def Run(self, solver):
4477    self.__method(self.__constraint, *self.__args)
def Priority(self):
4479  def Priority(self):
4480    return Solver.DELAYED_PRIORITY if self.__delayed else Solver.NORMAL_PRIORITY

This method returns the priority of the demon. Usually a demon is fast, slow or normal. Immediate demons are reserved for internal use to maintain variables.

def DebugString(self):
4482  def DebugString(self):
4483    return 'PyConstraintDemon'
class PyConstraint(Constraint):
4486class PyConstraint(Constraint):
4487
4488  def __init__(self, solver):
4489    Constraint.__init__(self, solver)
4490    self.__demons = []
4491
4492  def Demon(self, method, *args):
4493    demon = PyConstraintDemon(self, method, False, *args)
4494    self.__demons.append(demon)
4495    return demon
4496
4497  def DelayedDemon(self, method, *args):
4498    demon = PyConstraintDemon(self, method, True, *args)
4499    self.__demons.append(demon)
4500    return demon
4501
4502  def InitialPropagateDemon(self):
4503    return self.solver().ConstraintInitialPropagateCallback(self)
4504
4505  def DelayedInitialPropagateDemon(self):
4506    return self.solver().DelayedConstraintInitialPropagateCallback(self)
4507
4508  def InitialPropagateWrapper(self):
4509    try:
4510      self.InitialPropagate()
4511    except Exception as e:
4512      if 'CP Solver fail' in str(e):
4513        self.solver().ShouldFail()
4514      else:
4515        raise
4516
4517  def DebugString(self):
4518    return "PyConstraint"

A constraint is the main modeling object. It provides two methods:

  • Post() is responsible for creating the demons and attaching them to immediate demons().
  • InitialPropagate() is called once just after Post and performs the initial propagation. The subsequent propagations will be performed by the demons Posted during the post() method.
PyConstraint(solver)
4488  def __init__(self, solver):
4489    Constraint.__init__(self, solver)
4490    self.__demons = []
def Demon(self, method, *args):
4492  def Demon(self, method, *args):
4493    demon = PyConstraintDemon(self, method, False, *args)
4494    self.__demons.append(demon)
4495    return demon
def DelayedDemon(self, method, *args):
4497  def DelayedDemon(self, method, *args):
4498    demon = PyConstraintDemon(self, method, True, *args)
4499    self.__demons.append(demon)
4500    return demon
def InitialPropagateDemon(self):
4502  def InitialPropagateDemon(self):
4503    return self.solver().ConstraintInitialPropagateCallback(self)
def DelayedInitialPropagateDemon(self):
4505  def DelayedInitialPropagateDemon(self):
4506    return self.solver().DelayedConstraintInitialPropagateCallback(self)
def InitialPropagateWrapper(self):
4508  def InitialPropagateWrapper(self):
4509    try:
4510      self.InitialPropagate()
4511    except Exception as e:
4512      if 'CP Solver fail' in str(e):
4513        self.solver().ShouldFail()
4514      else:
4515        raise

This method performs the initial propagation of the constraint. It is called just after the post.

def DebugString(self):
4517  def DebugString(self):
4518    return "PyConstraint"
class RoutingIndexManager:
4522class RoutingIndexManager(object):
4523    r"""
4524    Manager for any NodeIndex <-> variable index conversion. The routing solver
4525    uses variable indices internally and through its API. These variable indices
4526    are tricky to manage directly because one Node can correspond to a multitude
4527    of variables, depending on the number of times they appear in the model, and
4528    if they're used as start and/or end points. This class aims to simplify
4529    variable index usage, allowing users to use NodeIndex instead.
4530
4531    Usage:
4532
4533      .. code-block:: c++
4534
4535          auto starts_ends = ...;  /// These are NodeIndex.
4536          RoutingIndexManager manager(10, 4, starts_ends);  // 10 nodes, 4 vehicles.
4537          RoutingModel model(manager);
4538
4539    Then, use 'manager.NodeToIndex(node)' whenever model requires a variable
4540    index.
4541
4542    Note: the mapping between node indices and variables indices is subject to
4543    change so no assumption should be made on it. The only guarantee is that
4544    indices range between 0 and n-1, where n = number of vehicles * 2 (for start
4545    and end nodes) + number of non-start or end nodes.
4546    """
4547
4548    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4549    __repr__ = _swig_repr
4550
4551    def __init__(self, *args):
4552        _pywrapcp.RoutingIndexManager_swiginit(self, _pywrapcp.new_RoutingIndexManager(*args))
4553    __swig_destroy__ = _pywrapcp.delete_RoutingIndexManager
4554
4555    def GetNumberOfNodes(self):
4556        return _pywrapcp.RoutingIndexManager_GetNumberOfNodes(self)
4557
4558    def GetNumberOfVehicles(self):
4559        return _pywrapcp.RoutingIndexManager_GetNumberOfVehicles(self)
4560
4561    def GetNumberOfIndices(self):
4562        return _pywrapcp.RoutingIndexManager_GetNumberOfIndices(self)
4563
4564    def GetStartIndex(self, vehicle):
4565        return _pywrapcp.RoutingIndexManager_GetStartIndex(self, vehicle)
4566
4567    def GetEndIndex(self, vehicle):
4568        return _pywrapcp.RoutingIndexManager_GetEndIndex(self, vehicle)
4569
4570    def NodeToIndex(self, node):
4571        return _pywrapcp.RoutingIndexManager_NodeToIndex(self, node)
4572
4573    def IndexToNode(self, index):
4574        return _pywrapcp.RoutingIndexManager_IndexToNode(self, index)

Manager for any NodeIndex <-> variable index conversion. The routing solver uses variable indices internally and through its API. These variable indices are tricky to manage directly because one Node can correspond to a multitude of variables, depending on the number of times they appear in the model, and if they're used as start and/or end points. This class aims to simplify variable index usage, allowing users to use NodeIndex instead.

Usage:

.. code-block:: c++

auto starts_ends = ...;  /// These are NodeIndex.
RoutingIndexManager manager(10, 4, starts_ends);  // 10 nodes, 4 vehicles.
RoutingModel model(manager);

Then, use 'manager.NodeToIndex(node)' whenever model requires a variable index.

Note: the mapping between node indices and variables indices is subject to change so no assumption should be made on it. The only guarantee is that indices range between 0 and n-1, where n = number of vehicles * 2 (for start and end nodes) + number of non-start or end nodes.

RoutingIndexManager(*args)
4551    def __init__(self, *args):
4552        _pywrapcp.RoutingIndexManager_swiginit(self, _pywrapcp.new_RoutingIndexManager(*args))
thisown

The membership flag

def GetNumberOfNodes(self):
4555    def GetNumberOfNodes(self):
4556        return _pywrapcp.RoutingIndexManager_GetNumberOfNodes(self)
def GetNumberOfVehicles(self):
4558    def GetNumberOfVehicles(self):
4559        return _pywrapcp.RoutingIndexManager_GetNumberOfVehicles(self)
def GetNumberOfIndices(self):
4561    def GetNumberOfIndices(self):
4562        return _pywrapcp.RoutingIndexManager_GetNumberOfIndices(self)
def GetStartIndex(self, vehicle):
4564    def GetStartIndex(self, vehicle):
4565        return _pywrapcp.RoutingIndexManager_GetStartIndex(self, vehicle)
def GetEndIndex(self, vehicle):
4567    def GetEndIndex(self, vehicle):
4568        return _pywrapcp.RoutingIndexManager_GetEndIndex(self, vehicle)
def NodeToIndex(self, node):
4570    def NodeToIndex(self, node):
4571        return _pywrapcp.RoutingIndexManager_NodeToIndex(self, node)
def IndexToNode(self, index):
4573    def IndexToNode(self, index):
4574        return _pywrapcp.RoutingIndexManager_IndexToNode(self, index)
def DefaultRoutingModelParameters():
4579def DefaultRoutingModelParameters():
4580    return _pywrapcp.DefaultRoutingModelParameters()
def DefaultRoutingSearchParameters():
4582def DefaultRoutingSearchParameters():
4583    return _pywrapcp.DefaultRoutingSearchParameters()
def FindErrorInRoutingSearchParameters(search_parameters):
4585def FindErrorInRoutingSearchParameters(search_parameters):
4586    r"""
4587    Returns an empty std::string if the routing search parameters are valid, and
4588    a non-empty, human readable error description if they're not.
4589    """
4590    return _pywrapcp.FindErrorInRoutingSearchParameters(search_parameters)

Returns an empty std::string if the routing search parameters are valid, and a non-empty, human readable error description if they're not.

class FirstSolutionStrategy:
4594class FirstSolutionStrategy(object):
4595    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4596    __repr__ = _swig_repr
4597
4598    def __init__(self):
4599        _pywrapcp.FirstSolutionStrategy_swiginit(self, _pywrapcp.new_FirstSolutionStrategy())
4600    __swig_destroy__ = _pywrapcp.delete_FirstSolutionStrategy
FirstSolutionStrategy()
4598    def __init__(self):
4599        _pywrapcp.FirstSolutionStrategy_swiginit(self, _pywrapcp.new_FirstSolutionStrategy())
thisown

The membership flag

class LocalSearchMetaheuristic:
4604class LocalSearchMetaheuristic(object):
4605    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4606    __repr__ = _swig_repr
4607
4608    def __init__(self):
4609        _pywrapcp.LocalSearchMetaheuristic_swiginit(self, _pywrapcp.new_LocalSearchMetaheuristic())
4610    __swig_destroy__ = _pywrapcp.delete_LocalSearchMetaheuristic
LocalSearchMetaheuristic()
4608    def __init__(self):
4609        _pywrapcp.LocalSearchMetaheuristic_swiginit(self, _pywrapcp.new_LocalSearchMetaheuristic())
thisown

The membership flag

class PathsMetadata:
4614class PathsMetadata(object):
4615    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4616    __repr__ = _swig_repr
4617
4618    def __init__(self, manager):
4619        _pywrapcp.PathsMetadata_swiginit(self, _pywrapcp.new_PathsMetadata(manager))
4620
4621    def IsStart(self, node):
4622        return _pywrapcp.PathsMetadata_IsStart(self, node)
4623
4624    def IsEnd(self, node):
4625        return _pywrapcp.PathsMetadata_IsEnd(self, node)
4626
4627    def GetPath(self, start_or_end_node):
4628        return _pywrapcp.PathsMetadata_GetPath(self, start_or_end_node)
4629
4630    def Starts(self):
4631        return _pywrapcp.PathsMetadata_Starts(self)
4632
4633    def Ends(self):
4634        return _pywrapcp.PathsMetadata_Ends(self)
4635    __swig_destroy__ = _pywrapcp.delete_PathsMetadata
PathsMetadata(manager)
4618    def __init__(self, manager):
4619        _pywrapcp.PathsMetadata_swiginit(self, _pywrapcp.new_PathsMetadata(manager))
thisown

The membership flag

def IsStart(self, node):
4621    def IsStart(self, node):
4622        return _pywrapcp.PathsMetadata_IsStart(self, node)
def IsEnd(self, node):
4624    def IsEnd(self, node):
4625        return _pywrapcp.PathsMetadata_IsEnd(self, node)
def GetPath(self, start_or_end_node):
4627    def GetPath(self, start_or_end_node):
4628        return _pywrapcp.PathsMetadata_GetPath(self, start_or_end_node)
def Starts(self):
4630    def Starts(self):
4631        return _pywrapcp.PathsMetadata_Starts(self)
def Ends(self):
4633    def Ends(self):
4634        return _pywrapcp.PathsMetadata_Ends(self)
class RoutingModel:
4639class RoutingModel(object):
4640    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4641    __repr__ = _swig_repr
4642    ROUTING_NOT_SOLVED = _pywrapcp.RoutingModel_ROUTING_NOT_SOLVED
4643    r""" Problem not solved yet (before calling RoutingModel::Solve())."""
4644    ROUTING_SUCCESS = _pywrapcp.RoutingModel_ROUTING_SUCCESS
4645    r""" Problem solved successfully after calling RoutingModel::Solve()."""
4646    ROUTING_PARTIAL_SUCCESS_LOCAL_OPTIMUM_NOT_REACHED = _pywrapcp.RoutingModel_ROUTING_PARTIAL_SUCCESS_LOCAL_OPTIMUM_NOT_REACHED
4647    r"""
4648    Problem solved successfully after calling RoutingModel::Solve(), except
4649    that a local optimum has not been reached. Leaving more time would allow
4650    improving the solution.
4651    """
4652    ROUTING_FAIL = _pywrapcp.RoutingModel_ROUTING_FAIL
4653    r""" No solution found to the problem after calling RoutingModel::Solve()."""
4654    ROUTING_FAIL_TIMEOUT = _pywrapcp.RoutingModel_ROUTING_FAIL_TIMEOUT
4655    r""" Time limit reached before finding a solution with RoutingModel::Solve()."""
4656    ROUTING_INVALID = _pywrapcp.RoutingModel_ROUTING_INVALID
4657    r""" Model, model parameters or flags are not valid."""
4658    ROUTING_INFEASIBLE = _pywrapcp.RoutingModel_ROUTING_INFEASIBLE
4659    r""" Problem proven to be infeasible."""
4660    PICKUP_AND_DELIVERY_NO_ORDER = _pywrapcp.RoutingModel_PICKUP_AND_DELIVERY_NO_ORDER
4661    r""" Any precedence is accepted."""
4662    PICKUP_AND_DELIVERY_LIFO = _pywrapcp.RoutingModel_PICKUP_AND_DELIVERY_LIFO
4663    r""" Deliveries must be performed in reverse order of pickups."""
4664    PICKUP_AND_DELIVERY_FIFO = _pywrapcp.RoutingModel_PICKUP_AND_DELIVERY_FIFO
4665    r""" Deliveries must be performed in the same order as pickups."""
4666
4667    def __init__(self, *args):
4668        _pywrapcp.RoutingModel_swiginit(self, _pywrapcp.new_RoutingModel(*args))
4669    __swig_destroy__ = _pywrapcp.delete_RoutingModel
4670
4671    def RegisterUnaryTransitVector(self, values):
4672        r""" Registers 'callback' and returns its index."""
4673        return _pywrapcp.RoutingModel_RegisterUnaryTransitVector(self, values)
4674
4675    def RegisterUnaryTransitCallback(self, callback):
4676        return _pywrapcp.RoutingModel_RegisterUnaryTransitCallback(self, callback)
4677
4678    def RegisterPositiveUnaryTransitCallback(self, callback):
4679        return _pywrapcp.RoutingModel_RegisterPositiveUnaryTransitCallback(self, callback)
4680
4681    def RegisterTransitMatrix(self, values):
4682        return _pywrapcp.RoutingModel_RegisterTransitMatrix(self, values)
4683
4684    def RegisterTransitCallback(self, callback):
4685        return _pywrapcp.RoutingModel_RegisterTransitCallback(self, callback)
4686
4687    def RegisterPositiveTransitCallback(self, callback):
4688        return _pywrapcp.RoutingModel_RegisterPositiveTransitCallback(self, callback)
4689
4690    def TransitCallback(self, callback_index):
4691        return _pywrapcp.RoutingModel_TransitCallback(self, callback_index)
4692
4693    def UnaryTransitCallbackOrNull(self, callback_index):
4694        return _pywrapcp.RoutingModel_UnaryTransitCallbackOrNull(self, callback_index)
4695
4696    def AddDimension(self, evaluator_index, slack_max, capacity, fix_start_cumul_to_zero, name):
4697        r"""
4698        Model creation
4699        Methods to add dimensions to routes; dimensions represent quantities
4700        accumulated at nodes along the routes. They represent quantities such as
4701        weights or volumes carried along the route, or distance or times.
4702        Quantities at a node are represented by "cumul" variables and the increase
4703        or decrease of quantities between nodes are represented by "transit"
4704        variables. These variables are linked as follows:
4705        if j == next(i), cumul(j) = cumul(i) + transit(i, j) + slack(i)
4706        where slack is a positive slack variable (can represent waiting times for
4707        a time dimension).
4708        Setting the value of fix_start_cumul_to_zero to true will force the
4709        "cumul" variable of the start node of all vehicles to be equal to 0.
4710        Creates a dimension where the transit variable is constrained to be
4711        equal to evaluator(i, next(i)); 'slack_max' is the upper bound of the
4712        slack variable and 'capacity' is the upper bound of the cumul variables.
4713        'name' is the name used to reference the dimension; this name is used to
4714        get cumul and transit variables from the routing model.
4715        Returns false if a dimension with the same name has already been created
4716        (and doesn't create the new dimension).
4717        Takes ownership of the callback 'evaluator'.
4718        """
4719        return _pywrapcp.RoutingModel_AddDimension(self, evaluator_index, slack_max, capacity, fix_start_cumul_to_zero, name)
4720
4721    def AddDimensionWithVehicleTransits(self, evaluator_indices, slack_max, capacity, fix_start_cumul_to_zero, name):
4722        return _pywrapcp.RoutingModel_AddDimensionWithVehicleTransits(self, evaluator_indices, slack_max, capacity, fix_start_cumul_to_zero, name)
4723
4724    def AddDimensionWithVehicleCapacity(self, evaluator_index, slack_max, vehicle_capacities, fix_start_cumul_to_zero, name):
4725        return _pywrapcp.RoutingModel_AddDimensionWithVehicleCapacity(self, evaluator_index, slack_max, vehicle_capacities, fix_start_cumul_to_zero, name)
4726
4727    def AddDimensionWithVehicleTransitAndCapacity(self, evaluator_indices, slack_max, vehicle_capacities, fix_start_cumul_to_zero, name):
4728        return _pywrapcp.RoutingModel_AddDimensionWithVehicleTransitAndCapacity(self, evaluator_indices, slack_max, vehicle_capacities, fix_start_cumul_to_zero, name)
4729
4730    def AddConstantDimensionWithSlack(self, value, capacity, slack_max, fix_start_cumul_to_zero, name):
4731        r"""
4732        Creates a dimension where the transit variable is constrained to be
4733        equal to 'value'; 'capacity' is the upper bound of the cumul variables.
4734        'name' is the name used to reference the dimension; this name is used to
4735        get cumul and transit variables from the routing model.
4736        Returns a pair consisting of an index to the registered unary transit
4737        callback and a bool denoting whether the dimension has been created.
4738        It is false if a dimension with the same name has already been created
4739        (and doesn't create the new dimension but still register a new callback).
4740        """
4741        return _pywrapcp.RoutingModel_AddConstantDimensionWithSlack(self, value, capacity, slack_max, fix_start_cumul_to_zero, name)
4742
4743    def AddConstantDimension(self, value, capacity, fix_start_cumul_to_zero, name):
4744        return _pywrapcp.RoutingModel_AddConstantDimension(self, value, capacity, fix_start_cumul_to_zero, name)
4745
4746    def AddVectorDimension(self, values, capacity, fix_start_cumul_to_zero, name):
4747        r"""
4748        Creates a dimension where the transit variable is constrained to be
4749        equal to 'values[i]' for node i; 'capacity' is the upper bound of
4750        the cumul variables. 'name' is the name used to reference the dimension;
4751        this name is used to get cumul and transit variables from the routing
4752        model.
4753        Returns a pair consisting of an index to the registered unary transit
4754        callback and a bool denoting whether the dimension has been created.
4755        It is false if a dimension with the same name has already been created
4756        (and doesn't create the new dimension but still register a new callback).
4757        """
4758        return _pywrapcp.RoutingModel_AddVectorDimension(self, values, capacity, fix_start_cumul_to_zero, name)
4759
4760    def AddMatrixDimension(self, values, capacity, fix_start_cumul_to_zero, name):
4761        r"""
4762        Creates a dimension where the transit variable is constrained to be
4763        equal to 'values[i][next(i)]' for node i; 'capacity' is the upper bound of
4764        the cumul variables. 'name' is the name used to reference the dimension;
4765        this name is used to get cumul and transit variables from the routing
4766        model.
4767        Returns a pair consisting of an index to the registered transit callback
4768        and a bool denoting whether the dimension has been created.
4769        It is false if a dimension with the same name has already been created
4770        (and doesn't create the new dimension but still register a new callback).
4771        """
4772        return _pywrapcp.RoutingModel_AddMatrixDimension(self, values, capacity, fix_start_cumul_to_zero, name)
4773
4774    def MakePathSpansAndTotalSlacks(self, dimension, spans, total_slacks):
4775        r"""
4776        For every vehicle of the routing model:
4777        - if total_slacks[vehicle] is not nullptr, constrains it to be the sum of
4778          slacks on that vehicle, that is,
4779          dimension->CumulVar(end) - dimension->CumulVar(start) -
4780          sum_{node in path of vehicle} dimension->FixedTransitVar(node).
4781        - if spans[vehicle] is not nullptr, constrains it to be
4782          dimension->CumulVar(end) - dimension->CumulVar(start)
4783        This does stronger propagation than a decomposition, and takes breaks into
4784        account.
4785        """
4786        return _pywrapcp.RoutingModel_MakePathSpansAndTotalSlacks(self, dimension, spans, total_slacks)
4787
4788    def GetAllDimensionNames(self):
4789        r""" Outputs the names of all dimensions added to the routing engine."""
4790        return _pywrapcp.RoutingModel_GetAllDimensionNames(self)
4791
4792    def GetDimensions(self):
4793        r""" Returns all dimensions of the model."""
4794        return _pywrapcp.RoutingModel_GetDimensions(self)
4795
4796    def GetDimensionsWithSoftOrSpanCosts(self):
4797        r""" Returns dimensions with soft or vehicle span costs."""
4798        return _pywrapcp.RoutingModel_GetDimensionsWithSoftOrSpanCosts(self)
4799
4800    def GetDimensionsWithGlobalCumulOptimizers(self):
4801        r""" Returns the dimensions which have [global|local]_dimension_optimizers_."""
4802        return _pywrapcp.RoutingModel_GetDimensionsWithGlobalCumulOptimizers(self)
4803
4804    def GetDimensionsWithLocalCumulOptimizers(self):
4805        return _pywrapcp.RoutingModel_GetDimensionsWithLocalCumulOptimizers(self)
4806
4807    def HasGlobalCumulOptimizer(self, dimension):
4808        r""" Returns whether the given dimension has global/local cumul optimizers."""
4809        return _pywrapcp.RoutingModel_HasGlobalCumulOptimizer(self, dimension)
4810
4811    def HasLocalCumulOptimizer(self, dimension):
4812        return _pywrapcp.RoutingModel_HasLocalCumulOptimizer(self, dimension)
4813
4814    def GetMutableGlobalCumulLPOptimizer(self, dimension):
4815        r"""
4816        Returns the global/local dimension cumul optimizer for a given dimension,
4817        or nullptr if there is none.
4818        """
4819        return _pywrapcp.RoutingModel_GetMutableGlobalCumulLPOptimizer(self, dimension)
4820
4821    def GetMutableGlobalCumulMPOptimizer(self, dimension):
4822        return _pywrapcp.RoutingModel_GetMutableGlobalCumulMPOptimizer(self, dimension)
4823
4824    def GetMutableLocalCumulLPOptimizer(self, dimension):
4825        return _pywrapcp.RoutingModel_GetMutableLocalCumulLPOptimizer(self, dimension)
4826
4827    def GetMutableLocalCumulMPOptimizer(self, dimension):
4828        return _pywrapcp.RoutingModel_GetMutableLocalCumulMPOptimizer(self, dimension)
4829
4830    def HasDimension(self, dimension_name):
4831        r""" Returns true if a dimension exists for a given dimension name."""
4832        return _pywrapcp.RoutingModel_HasDimension(self, dimension_name)
4833
4834    def GetDimensionOrDie(self, dimension_name):
4835        r""" Returns a dimension from its name. Dies if the dimension does not exist."""
4836        return _pywrapcp.RoutingModel_GetDimensionOrDie(self, dimension_name)
4837
4838    def GetMutableDimension(self, dimension_name):
4839        r"""
4840        Returns a dimension from its name. Returns nullptr if the dimension does
4841        not exist.
4842        """
4843        return _pywrapcp.RoutingModel_GetMutableDimension(self, dimension_name)
4844
4845    def SetPrimaryConstrainedDimension(self, dimension_name):
4846        r"""
4847        Set the given dimension as "primary constrained". As of August 2013, this
4848        is only used by ArcIsMoreConstrainedThanArc().
4849        "dimension" must be the name of an existing dimension, or be empty, in
4850        which case there will not be a primary dimension after this call.
4851        """
4852        return _pywrapcp.RoutingModel_SetPrimaryConstrainedDimension(self, dimension_name)
4853
4854    def GetPrimaryConstrainedDimension(self):
4855        r""" Get the primary constrained dimension, or an empty string if it is unset."""
4856        return _pywrapcp.RoutingModel_GetPrimaryConstrainedDimension(self)
4857
4858    def AddResourceGroup(self):
4859        r"""
4860        Adds a resource group to the routing model. Returns its index in
4861        resource_groups_.
4862        """
4863        return _pywrapcp.RoutingModel_AddResourceGroup(self)
4864
4865    def GetResourceGroups(self):
4866        return _pywrapcp.RoutingModel_GetResourceGroups(self)
4867
4868    def GetResourceGroup(self, rg_index):
4869        return _pywrapcp.RoutingModel_GetResourceGroup(self, rg_index)
4870
4871    def GetDimensionResourceGroupIndices(self, dimension):
4872        r"""
4873        Returns the indices of resource groups for this dimension. This method can
4874        only be called after the model has been closed.
4875        """
4876        return _pywrapcp.RoutingModel_GetDimensionResourceGroupIndices(self, dimension)
4877
4878    def GetDimensionResourceGroupIndex(self, dimension):
4879        r"""
4880        Returns the index of the resource group attached to the dimension.
4881        DCHECKS that there's exactly one resource group for this dimension.
4882        """
4883        return _pywrapcp.RoutingModel_GetDimensionResourceGroupIndex(self, dimension)
4884
4885    def AddDisjunction(self, *args):
4886        r"""
4887        Adds a disjunction constraint on the indices: exactly 'max_cardinality' of
4888        the indices are active. Start and end indices of any vehicle cannot be
4889        part of a disjunction.
4890
4891        If a penalty is given, at most 'max_cardinality' of the indices can be
4892        active, and if less are active, 'penalty' is payed per inactive index.
4893        This is equivalent to adding the constraint:
4894            p + Sum(i)active[i] == max_cardinality
4895        where p is an integer variable, and the following cost to the cost
4896        function:
4897            p * penalty.
4898        'penalty' must be positive to make the disjunction optional; a negative
4899        penalty will force 'max_cardinality' indices of the disjunction to be
4900        performed, and therefore p == 0.
4901        Note: passing a vector with a single index will model an optional index
4902        with a penalty cost if it is not visited.
4903        """
4904        return _pywrapcp.RoutingModel_AddDisjunction(self, *args)
4905
4906    def GetDisjunctionIndices(self, index):
4907        r""" Returns the indices of the disjunctions to which an index belongs."""
4908        return _pywrapcp.RoutingModel_GetDisjunctionIndices(self, index)
4909
4910    def GetDisjunctionPenalty(self, index):
4911        r""" Returns the penalty of the node disjunction of index 'index'."""
4912        return _pywrapcp.RoutingModel_GetDisjunctionPenalty(self, index)
4913
4914    def GetDisjunctionMaxCardinality(self, index):
4915        r"""
4916        Returns the maximum number of possible active nodes of the node
4917        disjunction of index 'index'.
4918        """
4919        return _pywrapcp.RoutingModel_GetDisjunctionMaxCardinality(self, index)
4920
4921    def GetNumberOfDisjunctions(self):
4922        r""" Returns the number of node disjunctions in the model."""
4923        return _pywrapcp.RoutingModel_GetNumberOfDisjunctions(self)
4924
4925    def HasMandatoryDisjunctions(self):
4926        r"""
4927        Returns true if the model contains mandatory disjunctions (ones with
4928        kNoPenalty as penalty).
4929        """
4930        return _pywrapcp.RoutingModel_HasMandatoryDisjunctions(self)
4931
4932    def HasMaxCardinalityConstrainedDisjunctions(self):
4933        r"""
4934        Returns true if the model contains at least one disjunction which is
4935        constrained by its max_cardinality.
4936        """
4937        return _pywrapcp.RoutingModel_HasMaxCardinalityConstrainedDisjunctions(self)
4938
4939    def GetPerfectBinaryDisjunctions(self):
4940        r"""
4941        Returns the list of all perfect binary disjunctions, as pairs of variable
4942        indices: a disjunction is "perfect" when its variables do not appear in
4943        any other disjunction. Each pair is sorted (lowest variable index first),
4944        and the output vector is also sorted (lowest pairs first).
4945        """
4946        return _pywrapcp.RoutingModel_GetPerfectBinaryDisjunctions(self)
4947
4948    def IgnoreDisjunctionsAlreadyForcedToZero(self):
4949        r"""
4950        SPECIAL: Makes the solver ignore all the disjunctions whose active
4951        variables are all trivially zero (i.e. Max() == 0), by setting their
4952        max_cardinality to 0.
4953        This can be useful when using the BaseBinaryDisjunctionNeighborhood
4954        operators, in the context of arc-based routing.
4955        """
4956        return _pywrapcp.RoutingModel_IgnoreDisjunctionsAlreadyForcedToZero(self)
4957
4958    def AddSoftSameVehicleConstraint(self, indices, cost):
4959        r"""
4960        Adds a soft constraint to force a set of variable indices to be on the
4961        same vehicle. If all nodes are not on the same vehicle, each extra vehicle
4962        used adds 'cost' to the cost function.
4963        """
4964        return _pywrapcp.RoutingModel_AddSoftSameVehicleConstraint(self, indices, cost)
4965
4966    def SetAllowedVehiclesForIndex(self, vehicles, index):
4967        r"""
4968        Sets the vehicles which can visit a given node. If the node is in a
4969        disjunction, this will not prevent it from being unperformed.
4970        Specifying an empty vector of vehicles has no effect (all vehicles
4971        will be allowed to visit the node).
4972        """
4973        return _pywrapcp.RoutingModel_SetAllowedVehiclesForIndex(self, vehicles, index)
4974
4975    def IsVehicleAllowedForIndex(self, vehicle, index):
4976        r""" Returns true if a vehicle is allowed to visit a given node."""
4977        return _pywrapcp.RoutingModel_IsVehicleAllowedForIndex(self, vehicle, index)
4978
4979    def AddPickupAndDelivery(self, pickup, delivery):
4980        r"""
4981        Notifies that index1 and index2 form a pair of nodes which should belong
4982        to the same route. This methods helps the search find better solutions,
4983        especially in the local search phase.
4984        It should be called each time you have an equality constraint linking
4985        the vehicle variables of two node (including for instance pickup and
4986        delivery problems):
4987            Solver* const solver = routing.solver();
4988            int64_t index1 = manager.NodeToIndex(node1);
4989            int64_t index2 = manager.NodeToIndex(node2);
4990            solver->AddConstraint(solver->MakeEquality(
4991                routing.VehicleVar(index1),
4992                routing.VehicleVar(index2)));
4993            routing.AddPickupAndDelivery(index1, index2);
4994        """
4995        return _pywrapcp.RoutingModel_AddPickupAndDelivery(self, pickup, delivery)
4996
4997    def AddPickupAndDeliverySets(self, pickup_disjunction, delivery_disjunction):
4998        r"""
4999        Same as AddPickupAndDelivery but notifying that the performed node from
5000        the disjunction of index 'pickup_disjunction' is on the same route as the
5001        performed node from the disjunction of index 'delivery_disjunction'.
5002        """
5003        return _pywrapcp.RoutingModel_AddPickupAndDeliverySets(self, pickup_disjunction, delivery_disjunction)
5004
5005    def GetPickupIndexPairs(self, node_index):
5006        r"""
5007        Returns pairs for which the node is a pickup; the first element of each
5008        pair is the index in the pickup and delivery pairs list in which the
5009        pickup appears, the second element is its index in the pickups list.
5010        """
5011        return _pywrapcp.RoutingModel_GetPickupIndexPairs(self, node_index)
5012
5013    def GetDeliveryIndexPairs(self, node_index):
5014        r""" Same as above for deliveries."""
5015        return _pywrapcp.RoutingModel_GetDeliveryIndexPairs(self, node_index)
5016
5017    def SetPickupAndDeliveryPolicyOfAllVehicles(self, policy):
5018        r"""
5019        Sets the Pickup and delivery policy of all vehicles. It is equivalent to
5020        calling SetPickupAndDeliveryPolicyOfVehicle on all vehicles.
5021        """
5022        return _pywrapcp.RoutingModel_SetPickupAndDeliveryPolicyOfAllVehicles(self, policy)
5023
5024    def SetPickupAndDeliveryPolicyOfVehicle(self, policy, vehicle):
5025        return _pywrapcp.RoutingModel_SetPickupAndDeliveryPolicyOfVehicle(self, policy, vehicle)
5026
5027    def GetPickupAndDeliveryPolicyOfVehicle(self, vehicle):
5028        return _pywrapcp.RoutingModel_GetPickupAndDeliveryPolicyOfVehicle(self, vehicle)
5029
5030    def GetNumOfSingletonNodes(self):
5031        r"""
5032        Returns the number of non-start/end nodes which do not appear in a
5033        pickup/delivery pair.
5034        """
5035        return _pywrapcp.RoutingModel_GetNumOfSingletonNodes(self)
5036    TYPE_ADDED_TO_VEHICLE = _pywrapcp.RoutingModel_TYPE_ADDED_TO_VEHICLE
5037    r""" When visited, the number of types 'T' on the vehicle increases by one."""
5038    ADDED_TYPE_REMOVED_FROM_VEHICLE = _pywrapcp.RoutingModel_ADDED_TYPE_REMOVED_FROM_VEHICLE
5039    r"""
5040    When visited, one instance of type 'T' previously added to the route
5041    (TYPE_ADDED_TO_VEHICLE), if any, is removed from the vehicle.
5042    If the type was not previously added to the route or all added instances
5043    have already been removed, this visit has no effect on the types.
5044    """
5045    TYPE_ON_VEHICLE_UP_TO_VISIT = _pywrapcp.RoutingModel_TYPE_ON_VEHICLE_UP_TO_VISIT
5046    r"""
5047    With the following policy, the visit enforces that type 'T' is
5048    considered on the route from its start until this node is visited.
5049    """
5050    TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED = _pywrapcp.RoutingModel_TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED
5051    r"""
5052    The visit doesn't have an impact on the number of types 'T' on the
5053    route, as it's (virtually) added and removed directly.
5054    This policy can be used for visits which are part of an incompatibility
5055    or requirement set without affecting the type count on the route.
5056    """
5057
5058    def SetVisitType(self, index, type, type_policy):
5059        return _pywrapcp.RoutingModel_SetVisitType(self, index, type, type_policy)
5060
5061    def GetVisitType(self, index):
5062        return _pywrapcp.RoutingModel_GetVisitType(self, index)
5063
5064    def GetSingleNodesOfType(self, type):
5065        return _pywrapcp.RoutingModel_GetSingleNodesOfType(self, type)
5066
5067    def GetPairIndicesOfType(self, type):
5068        return _pywrapcp.RoutingModel_GetPairIndicesOfType(self, type)
5069
5070    def GetVisitTypePolicy(self, index):
5071        return _pywrapcp.RoutingModel_GetVisitTypePolicy(self, index)
5072
5073    def CloseVisitTypes(self):
5074        r"""
5075        This function should be called once all node visit types have been set and
5076        prior to adding any incompatibilities/requirements.
5077        "close" types.
5078        """
5079        return _pywrapcp.RoutingModel_CloseVisitTypes(self)
5080
5081    def GetNumberOfVisitTypes(self):
5082        return _pywrapcp.RoutingModel_GetNumberOfVisitTypes(self)
5083
5084    def AddHardTypeIncompatibility(self, type1, type2):
5085        r"""
5086        Incompatibilities:
5087        Two nodes with "hard" incompatible types cannot share the same route at
5088        all, while with a "temporal" incompatibility they can't be on the same
5089        route at the same time.
5090        """
5091        return _pywrapcp.RoutingModel_AddHardTypeIncompatibility(self, type1, type2)
5092
5093    def AddTemporalTypeIncompatibility(self, type1, type2):
5094        return _pywrapcp.RoutingModel_AddTemporalTypeIncompatibility(self, type1, type2)
5095
5096    def GetHardTypeIncompatibilitiesOfType(self, type):
5097        r""" Returns visit types incompatible with a given type."""
5098        return _pywrapcp.RoutingModel_GetHardTypeIncompatibilitiesOfType(self, type)
5099
5100    def GetTemporalTypeIncompatibilitiesOfType(self, type):
5101        return _pywrapcp.RoutingModel_GetTemporalTypeIncompatibilitiesOfType(self, type)
5102
5103    def HasHardTypeIncompatibilities(self):
5104        r"""
5105        Returns true iff any hard (resp. temporal) type incompatibilities have
5106        been added to the model.
5107        """
5108        return _pywrapcp.RoutingModel_HasHardTypeIncompatibilities(self)
5109
5110    def HasTemporalTypeIncompatibilities(self):
5111        return _pywrapcp.RoutingModel_HasTemporalTypeIncompatibilities(self)
5112
5113    def AddSameVehicleRequiredTypeAlternatives(self, dependent_type, required_type_alternatives):
5114        r"""
5115        Requirements:
5116        NOTE: As of 2019-04, cycles in the requirement graph are not supported,
5117        and lead to the dependent nodes being skipped if possible (otherwise
5118        the model is considered infeasible).
5119        The following functions specify that "dependent_type" requires at least
5120        one of the types in "required_type_alternatives".
5121
5122        For same-vehicle requirements, a node of dependent type type_D requires at
5123        least one node of type type_R among the required alternatives on the same
5124        route.
5125        """
5126        return _pywrapcp.RoutingModel_AddSameVehicleRequiredTypeAlternatives(self, dependent_type, required_type_alternatives)
5127
5128    def AddRequiredTypeAlternativesWhenAddingType(self, dependent_type, required_type_alternatives):
5129        r"""
5130        If type_D depends on type_R when adding type_D, any node_D of type_D and
5131        VisitTypePolicy TYPE_ADDED_TO_VEHICLE or
5132        TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED requires at least one type_R on its
5133        vehicle at the time node_D is visited.
5134        """
5135        return _pywrapcp.RoutingModel_AddRequiredTypeAlternativesWhenAddingType(self, dependent_type, required_type_alternatives)
5136
5137    def AddRequiredTypeAlternativesWhenRemovingType(self, dependent_type, required_type_alternatives):
5138        r"""
5139        The following requirements apply when visiting dependent nodes that remove
5140        their type from the route, i.e. type_R must be on the vehicle when type_D
5141        of VisitTypePolicy ADDED_TYPE_REMOVED_FROM_VEHICLE,
5142        TYPE_ON_VEHICLE_UP_TO_VISIT or TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED is
5143        visited.
5144        """
5145        return _pywrapcp.RoutingModel_AddRequiredTypeAlternativesWhenRemovingType(self, dependent_type, required_type_alternatives)
5146
5147    def GetSameVehicleRequiredTypeAlternativesOfType(self, type):
5148        r"""
5149        Returns the set of same-vehicle requirement alternatives for the given
5150        type.
5151        """
5152        return _pywrapcp.RoutingModel_GetSameVehicleRequiredTypeAlternativesOfType(self, type)
5153
5154    def GetRequiredTypeAlternativesWhenAddingType(self, type):
5155        r""" Returns the set of requirement alternatives when adding the given type."""
5156        return _pywrapcp.RoutingModel_GetRequiredTypeAlternativesWhenAddingType(self, type)
5157
5158    def GetRequiredTypeAlternativesWhenRemovingType(self, type):
5159        r""" Returns the set of requirement alternatives when removing the given type."""
5160        return _pywrapcp.RoutingModel_GetRequiredTypeAlternativesWhenRemovingType(self, type)
5161
5162    def HasSameVehicleTypeRequirements(self):
5163        r"""
5164        Returns true iff any same-route (resp. temporal) type requirements have
5165        been added to the model.
5166        """
5167        return _pywrapcp.RoutingModel_HasSameVehicleTypeRequirements(self)
5168
5169    def HasTemporalTypeRequirements(self):
5170        return _pywrapcp.RoutingModel_HasTemporalTypeRequirements(self)
5171
5172    def HasTypeRegulations(self):
5173        r"""
5174        Returns true iff the model has any incompatibilities or requirements set
5175        on node types.
5176        """
5177        return _pywrapcp.RoutingModel_HasTypeRegulations(self)
5178
5179    def UnperformedPenalty(self, var_index):
5180        r"""
5181        Get the "unperformed" penalty of a node. This is only well defined if the
5182        node is only part of a single Disjunction, and that disjunction has a
5183        penalty. For forced active nodes returns max int64_t. In all other cases,
5184        this returns 0.
5185        """
5186        return _pywrapcp.RoutingModel_UnperformedPenalty(self, var_index)
5187
5188    def UnperformedPenaltyOrValue(self, default_value, var_index):
5189        r"""
5190        Same as above except that it returns default_value instead of 0 when
5191        penalty is not well defined (default value is passed as first argument to
5192        simplify the usage of the method in a callback).
5193        """
5194        return _pywrapcp.RoutingModel_UnperformedPenaltyOrValue(self, default_value, var_index)
5195
5196    def GetDepot(self):
5197        r"""
5198        Returns the variable index of the first starting or ending node of all
5199        routes. If all routes start  and end at the same node (single depot), this
5200        is the node returned.
5201        """
5202        return _pywrapcp.RoutingModel_GetDepot(self)
5203
5204    def SetMaximumNumberOfActiveVehicles(self, max_active_vehicles):
5205        r"""
5206        Constrains the maximum number of active vehicles, aka the number of
5207        vehicles which do not have an empty route. For instance, this can be used
5208        to limit the number of routes in the case where there are fewer drivers
5209        than vehicles and that the fleet of vehicle is heterogeneous.
5210        """
5211        return _pywrapcp.RoutingModel_SetMaximumNumberOfActiveVehicles(self, max_active_vehicles)
5212
5213    def GetMaximumNumberOfActiveVehicles(self):
5214        r""" Returns the maximum number of active vehicles."""
5215        return _pywrapcp.RoutingModel_GetMaximumNumberOfActiveVehicles(self)
5216
5217    def SetArcCostEvaluatorOfAllVehicles(self, evaluator_index):
5218        r"""
5219        Sets the cost function of the model such that the cost of a segment of a
5220        route between node 'from' and 'to' is evaluator(from, to), whatever the
5221        route or vehicle performing the route.
5222        """
5223        return _pywrapcp.RoutingModel_SetArcCostEvaluatorOfAllVehicles(self, evaluator_index)
5224
5225    def SetArcCostEvaluatorOfVehicle(self, evaluator_index, vehicle):
5226        r""" Sets the cost function for a given vehicle route."""
5227        return _pywrapcp.RoutingModel_SetArcCostEvaluatorOfVehicle(self, evaluator_index, vehicle)
5228
5229    def SetFixedCostOfAllVehicles(self, cost):
5230        r"""
5231        Sets the fixed cost of all vehicle routes. It is equivalent to calling
5232        SetFixedCostOfVehicle on all vehicle routes.
5233        """
5234        return _pywrapcp.RoutingModel_SetFixedCostOfAllVehicles(self, cost)
5235
5236    def SetFixedCostOfVehicle(self, cost, vehicle):
5237        r""" Sets the fixed cost of one vehicle route."""
5238        return _pywrapcp.RoutingModel_SetFixedCostOfVehicle(self, cost, vehicle)
5239
5240    def GetFixedCostOfVehicle(self, vehicle):
5241        r"""
5242        Returns the route fixed cost taken into account if the route of the
5243        vehicle is not empty, aka there's at least one node on the route other
5244        than the first and last nodes.
5245        """
5246        return _pywrapcp.RoutingModel_GetFixedCostOfVehicle(self, vehicle)
5247
5248    def SetAmortizedCostFactorsOfAllVehicles(self, linear_cost_factor, quadratic_cost_factor):
5249        r"""
5250        The following methods set the linear and quadratic cost factors of
5251        vehicles (must be positive values). The default value of these parameters
5252        is zero for all vehicles.
5253
5254        When set, the cost_ of the model will contain terms aiming at reducing the
5255        number of vehicles used in the model, by adding the following to the
5256        objective for every vehicle v:
5257        INDICATOR(v used in the model) *
5258          [linear_cost_factor_of_vehicle_[v]
5259           - quadratic_cost_factor_of_vehicle_[v]*(square of length of route v)]
5260        i.e. for every used vehicle, we add the linear factor as fixed cost, and
5261        subtract the square of the route length multiplied by the quadratic
5262        factor. This second term aims at making the routes as dense as possible.
5263
5264        Sets the linear and quadratic cost factor of all vehicles.
5265        """
5266        return _pywrapcp.RoutingModel_SetAmortizedCostFactorsOfAllVehicles(self, linear_cost_factor, quadratic_cost_factor)
5267
5268    def SetAmortizedCostFactorsOfVehicle(self, linear_cost_factor, quadratic_cost_factor, vehicle):
5269        r""" Sets the linear and quadratic cost factor of the given vehicle."""
5270        return _pywrapcp.RoutingModel_SetAmortizedCostFactorsOfVehicle(self, linear_cost_factor, quadratic_cost_factor, vehicle)
5271
5272    def GetAmortizedLinearCostFactorOfVehicles(self):
5273        return _pywrapcp.RoutingModel_GetAmortizedLinearCostFactorOfVehicles(self)
5274
5275    def GetAmortizedQuadraticCostFactorOfVehicles(self):
5276        return _pywrapcp.RoutingModel_GetAmortizedQuadraticCostFactorOfVehicles(self)
5277
5278    def SetVehicleUsedWhenEmpty(self, is_used, vehicle):
5279        return _pywrapcp.RoutingModel_SetVehicleUsedWhenEmpty(self, is_used, vehicle)
5280
5281    def IsVehicleUsedWhenEmpty(self, vehicle):
5282        return _pywrapcp.RoutingModel_IsVehicleUsedWhenEmpty(self, vehicle)
5283
5284    def SetFirstSolutionEvaluator(self, evaluator):
5285        r"""
5286        Gets/sets the evaluator used during the search. Only relevant when
5287        RoutingSearchParameters.first_solution_strategy = EVALUATOR_STRATEGY.
5288        Takes ownership of evaluator.
5289        """
5290        return _pywrapcp.RoutingModel_SetFirstSolutionEvaluator(self, evaluator)
5291
5292    def AddLocalSearchOperator(self, ls_operator):
5293        r"""
5294        Adds a local search operator to the set of operators used to solve the
5295        vehicle routing problem.
5296        """
5297        return _pywrapcp.RoutingModel_AddLocalSearchOperator(self, ls_operator)
5298
5299    def AddSearchMonitor(self, monitor):
5300        r""" Adds a search monitor to the search used to solve the routing model."""
5301        return _pywrapcp.RoutingModel_AddSearchMonitor(self, monitor)
5302
5303    def AddAtSolutionCallback(self, callback):
5304        r"""
5305        Adds a callback called each time a solution is found during the search.
5306        This is a shortcut to creating a monitor to call the callback on
5307        AtSolution() and adding it with AddSearchMonitor.
5308        """
5309        return _pywrapcp.RoutingModel_AddAtSolutionCallback(self, callback)
5310
5311    def AddVariableMinimizedByFinalizer(self, var):
5312        r"""
5313        Adds a variable to minimize in the solution finalizer. The solution
5314        finalizer is called each time a solution is found during the search and
5315        allows to instantiate secondary variables (such as dimension cumul
5316        variables).
5317        """
5318        return _pywrapcp.RoutingModel_AddVariableMinimizedByFinalizer(self, var)
5319
5320    def AddVariableMaximizedByFinalizer(self, var):
5321        r"""
5322        Adds a variable to maximize in the solution finalizer (see above for
5323        information on the solution finalizer).
5324        """
5325        return _pywrapcp.RoutingModel_AddVariableMaximizedByFinalizer(self, var)
5326
5327    def AddWeightedVariableMinimizedByFinalizer(self, var, cost):
5328        r"""
5329        Adds a variable to minimize in the solution finalizer, with a weighted
5330        priority: the higher the more priority it has.
5331        """
5332        return _pywrapcp.RoutingModel_AddWeightedVariableMinimizedByFinalizer(self, var, cost)
5333
5334    def AddWeightedVariableMaximizedByFinalizer(self, var, cost):
5335        r"""
5336        Adds a variable to maximize in the solution finalizer, with a weighted
5337        priority: the higher the more priority it has.
5338        """
5339        return _pywrapcp.RoutingModel_AddWeightedVariableMaximizedByFinalizer(self, var, cost)
5340
5341    def AddVariableTargetToFinalizer(self, var, target):
5342        r"""
5343        Add a variable to set the closest possible to the target value in the
5344        solution finalizer.
5345        """
5346        return _pywrapcp.RoutingModel_AddVariableTargetToFinalizer(self, var, target)
5347
5348    def AddWeightedVariableTargetToFinalizer(self, var, target, cost):
5349        r"""
5350        Same as above with a weighted priority: the higher the cost, the more
5351        priority it has to be set close to the target value.
5352        """
5353        return _pywrapcp.RoutingModel_AddWeightedVariableTargetToFinalizer(self, var, target, cost)
5354
5355    def CloseModel(self):
5356        r"""
5357        Closes the current routing model; after this method is called, no
5358        modification to the model can be done, but RoutesToAssignment becomes
5359        available. Note that CloseModel() is automatically called by Solve() and
5360        other methods that produce solution.
5361        This is equivalent to calling
5362        CloseModelWithParameters(DefaultRoutingSearchParameters()).
5363        """
5364        return _pywrapcp.RoutingModel_CloseModel(self)
5365
5366    def CloseModelWithParameters(self, search_parameters):
5367        r"""
5368        Same as above taking search parameters (as of 10/2015 some the parameters
5369        have to be set when closing the model).
5370        """
5371        return _pywrapcp.RoutingModel_CloseModelWithParameters(self, search_parameters)
5372
5373    def Solve(self, assignment=None):
5374        r"""
5375        Solves the current routing model; closes the current model.
5376        This is equivalent to calling
5377        SolveWithParameters(DefaultRoutingSearchParameters())
5378        or
5379        SolveFromAssignmentWithParameters(assignment,
5380                                          DefaultRoutingSearchParameters()).
5381        """
5382        return _pywrapcp.RoutingModel_Solve(self, assignment)
5383
5384    def SolveWithParameters(self, search_parameters, solutions=None):
5385        r"""
5386        Solves the current routing model with the given parameters. If 'solutions'
5387        is specified, it will contain the k best solutions found during the search
5388        (from worst to best, including the one returned by this method), where k
5389        corresponds to the 'number_of_solutions_to_collect' in
5390        'search_parameters'. Note that the Assignment returned by the method and
5391        the ones in solutions are owned by the underlying solver and should not be
5392        deleted.
5393        """
5394        return _pywrapcp.RoutingModel_SolveWithParameters(self, search_parameters, solutions)
5395
5396    def SolveFromAssignmentWithParameters(self, assignment, search_parameters, solutions=None):
5397        r"""
5398        Same as above, except that if assignment is not null, it will be used as
5399        the initial solution.
5400        """
5401        return _pywrapcp.RoutingModel_SolveFromAssignmentWithParameters(self, assignment, search_parameters, solutions)
5402
5403    def SolveFromAssignmentsWithParameters(self, assignments, search_parameters, solutions=None):
5404        r"""
5405        Same as above but will try all assignments in order as first solutions
5406        until one succeeds.
5407        """
5408        return _pywrapcp.RoutingModel_SolveFromAssignmentsWithParameters(self, assignments, search_parameters, solutions)
5409
5410    def SetAssignmentFromOtherModelAssignment(self, target_assignment, source_model, source_assignment):
5411        r"""
5412        Given a "source_model" and its "source_assignment", resets
5413        "target_assignment" with the IntVar variables (nexts_, and vehicle_vars_
5414        if costs aren't homogeneous across vehicles) of "this" model, with the
5415        values set according to those in "other_assignment".
5416        The objective_element of target_assignment is set to this->cost_.
5417        """
5418        return _pywrapcp.RoutingModel_SetAssignmentFromOtherModelAssignment(self, target_assignment, source_model, source_assignment)
5419
5420    def ComputeLowerBound(self):
5421        r"""
5422        Computes a lower bound to the routing problem solving a linear assignment
5423        problem. The routing model must be closed before calling this method.
5424        Note that problems with node disjunction constraints (including optional
5425        nodes) and non-homogenous costs are not supported (the method returns 0 in
5426        these cases).
5427        """
5428        return _pywrapcp.RoutingModel_ComputeLowerBound(self)
5429
5430    def status(self):
5431        r""" Returns the current status of the routing model."""
5432        return _pywrapcp.RoutingModel_status(self)
5433
5434    def enable_deep_serialization(self):
5435        r""" Returns the value of the internal enable_deep_serialization_ parameter."""
5436        return _pywrapcp.RoutingModel_enable_deep_serialization(self)
5437
5438    def ApplyLocks(self, locks):
5439        r"""
5440        Applies a lock chain to the next search. 'locks' represents an ordered
5441        vector of nodes representing a partial route which will be fixed during
5442        the next search; it will constrain next variables such that:
5443        next[locks[i]] == locks[i+1].
5444
5445        Returns the next variable at the end of the locked chain; this variable is
5446        not locked. An assignment containing the locks can be obtained by calling
5447        PreAssignment().
5448        """
5449        return _pywrapcp.RoutingModel_ApplyLocks(self, locks)
5450
5451    def ApplyLocksToAllVehicles(self, locks, close_routes):
5452        r"""
5453        Applies lock chains to all vehicles to the next search, such that locks[p]
5454        is the lock chain for route p. Returns false if the locks do not contain
5455        valid routes; expects that the routes do not contain the depots,
5456        i.e. there are empty vectors in place of empty routes.
5457        If close_routes is set to true, adds the end nodes to the route of each
5458        vehicle and deactivates other nodes.
5459        An assignment containing the locks can be obtained by calling
5460        PreAssignment().
5461        """
5462        return _pywrapcp.RoutingModel_ApplyLocksToAllVehicles(self, locks, close_routes)
5463
5464    def PreAssignment(self):
5465        r"""
5466        Returns an assignment used to fix some of the variables of the problem.
5467        In practice, this assignment locks partial routes of the problem. This
5468        can be used in the context of locking the parts of the routes which have
5469        already been driven in online routing problems.
5470        """
5471        return _pywrapcp.RoutingModel_PreAssignment(self)
5472
5473    def MutablePreAssignment(self):
5474        return _pywrapcp.RoutingModel_MutablePreAssignment(self)
5475
5476    def WriteAssignment(self, file_name):
5477        r"""
5478        Writes the current solution to a file containing an AssignmentProto.
5479        Returns false if the file cannot be opened or if there is no current
5480        solution.
5481        """
5482        return _pywrapcp.RoutingModel_WriteAssignment(self, file_name)
5483
5484    def ReadAssignment(self, file_name):
5485        r"""
5486        Reads an assignment from a file and returns the current solution.
5487        Returns nullptr if the file cannot be opened or if the assignment is not
5488        valid.
5489        """
5490        return _pywrapcp.RoutingModel_ReadAssignment(self, file_name)
5491
5492    def RestoreAssignment(self, solution):
5493        r"""
5494        Restores an assignment as a solution in the routing model and returns the
5495        new solution. Returns nullptr if the assignment is not valid.
5496        """
5497        return _pywrapcp.RoutingModel_RestoreAssignment(self, solution)
5498
5499    def ReadAssignmentFromRoutes(self, routes, ignore_inactive_indices):
5500        r"""
5501        Restores the routes as the current solution. Returns nullptr if the
5502        solution cannot be restored (routes do not contain a valid solution). Note
5503        that calling this method will run the solver to assign values to the
5504        dimension variables; this may take considerable amount of time, especially
5505        when using dimensions with slack.
5506        """
5507        return _pywrapcp.RoutingModel_ReadAssignmentFromRoutes(self, routes, ignore_inactive_indices)
5508
5509    def RoutesToAssignment(self, routes, ignore_inactive_indices, close_routes, assignment):
5510        r"""
5511        Fills an assignment from a specification of the routes of the
5512        vehicles. The routes are specified as lists of variable indices that
5513        appear on the routes of the vehicles. The indices of the outer vector in
5514        'routes' correspond to vehicles IDs, the inner vector contains the
5515        variable indices on the routes for the given vehicle. The inner vectors
5516        must not contain the start and end indices, as these are determined by the
5517        routing model.  Sets the value of NextVars in the assignment, adding the
5518        variables to the assignment if necessary. The method does not touch other
5519        variables in the assignment. The method can only be called after the model
5520        is closed.  With ignore_inactive_indices set to false, this method will
5521        fail (return nullptr) in case some of the route contain indices that are
5522        deactivated in the model; when set to true, these indices will be
5523        skipped.  Returns true if routes were successfully
5524        loaded. However, such assignment still might not be a valid
5525        solution to the routing problem due to more complex constraints;
5526        it is advisible to call solver()->CheckSolution() afterwards.
5527        """
5528        return _pywrapcp.RoutingModel_RoutesToAssignment(self, routes, ignore_inactive_indices, close_routes, assignment)
5529
5530    def AssignmentToRoutes(self, assignment, routes):
5531        r"""
5532        Converts the solution in the given assignment to routes for all vehicles.
5533        Expects that assignment contains a valid solution (i.e. routes for all
5534        vehicles end with an end index for that vehicle).
5535        """
5536        return _pywrapcp.RoutingModel_AssignmentToRoutes(self, assignment, routes)
5537
5538    def CompactAssignment(self, assignment):
5539        r"""
5540        Converts the solution in the given assignment to routes for all vehicles.
5541        If the returned vector is route_indices, route_indices[i][j] is the index
5542        for jth location visited on route i. Note that contrary to
5543        AssignmentToRoutes, the vectors do include start and end locations.
5544        Returns a compacted version of the given assignment, in which all vehicles
5545        with id lower or equal to some N have non-empty routes, and all vehicles
5546        with id greater than N have empty routes. Does not take ownership of the
5547        returned object.
5548        If found, the cost of the compact assignment is the same as in the
5549        original assignment and it preserves the values of 'active' variables.
5550        Returns nullptr if a compact assignment was not found.
5551        This method only works in homogenous mode, and it only swaps equivalent
5552        vehicles (vehicles with the same start and end nodes). When creating the
5553        compact assignment, the empty plan is replaced by the route assigned to
5554        the compatible vehicle with the highest id. Note that with more complex
5555        constraints on vehicle variables, this method might fail even if a compact
5556        solution exists.
5557        This method changes the vehicle and dimension variables as necessary.
5558        While compacting the solution, only basic checks on vehicle variables are
5559        performed; if one of these checks fails no attempts to repair it are made
5560        (instead, the method returns nullptr).
5561        """
5562        return _pywrapcp.RoutingModel_CompactAssignment(self, assignment)
5563
5564    def CompactAndCheckAssignment(self, assignment):
5565        r"""
5566        Same as CompactAssignment() but also checks the validity of the final
5567        compact solution; if it is not valid, no attempts to repair it are made
5568        (instead, the method returns nullptr).
5569        """
5570        return _pywrapcp.RoutingModel_CompactAndCheckAssignment(self, assignment)
5571
5572    def AddToAssignment(self, var):
5573        r""" Adds an extra variable to the vehicle routing assignment."""
5574        return _pywrapcp.RoutingModel_AddToAssignment(self, var)
5575
5576    def AddIntervalToAssignment(self, interval):
5577        return _pywrapcp.RoutingModel_AddIntervalToAssignment(self, interval)
5578
5579    def PackCumulsOfOptimizerDimensionsFromAssignment(self, original_assignment, duration_limit, time_limit_was_reached=None):
5580        r"""
5581        For every dimension in the model with an optimizer in
5582        local/global_dimension_optimizers_, this method tries to pack the cumul
5583        values of the dimension, such that:
5584        - The cumul costs (span costs, soft lower and upper bound costs, etc) are
5585          minimized.
5586        - The cumuls of the ends of the routes are minimized for this given
5587          minimal cumul cost.
5588        - Given these minimal end cumuls, the route start cumuls are maximized.
5589        Returns the assignment resulting from allocating these packed cumuls with
5590        the solver, and nullptr if these cumuls could not be set by the solver.
5591        """
5592        return _pywrapcp.RoutingModel_PackCumulsOfOptimizerDimensionsFromAssignment(self, original_assignment, duration_limit, time_limit_was_reached)
5593
5594    def GetOrCreateNodeNeighborsByCostClass(self, num_neighbors):
5595        r"""
5596        Returns num_neighbors neighbors of all nodes for every cost class. The
5597        result is cached and is computed once.
5598        """
5599        return _pywrapcp.RoutingModel_GetOrCreateNodeNeighborsByCostClass(self, num_neighbors)
5600
5601    def AddLocalSearchFilter(self, filter):
5602        r"""
5603        Adds a custom local search filter to the list of filters used to speed up
5604        local search by pruning unfeasible variable assignments.
5605        Calling this method after the routing model has been closed (CloseModel()
5606        or Solve() has been called) has no effect.
5607        The routing model does not take ownership of the filter.
5608        """
5609        return _pywrapcp.RoutingModel_AddLocalSearchFilter(self, filter)
5610
5611    def Start(self, vehicle):
5612        r"""
5613        Model inspection.
5614        Returns the variable index of the starting node of a vehicle route.
5615        """
5616        return _pywrapcp.RoutingModel_Start(self, vehicle)
5617
5618    def End(self, vehicle):
5619        r""" Returns the variable index of the ending node of a vehicle route."""
5620        return _pywrapcp.RoutingModel_End(self, vehicle)
5621
5622    def IsStart(self, index):
5623        r""" Returns true if 'index' represents the first node of a route."""
5624        return _pywrapcp.RoutingModel_IsStart(self, index)
5625
5626    def IsEnd(self, index):
5627        r""" Returns true if 'index' represents the last node of a route."""
5628        return _pywrapcp.RoutingModel_IsEnd(self, index)
5629
5630    def VehicleIndex(self, index):
5631        r"""
5632        Returns the vehicle of the given start/end index, and -1 if the given
5633        index is not a vehicle start/end.
5634        """
5635        return _pywrapcp.RoutingModel_VehicleIndex(self, index)
5636
5637    def Next(self, assignment, index):
5638        r"""
5639        Assignment inspection
5640        Returns the variable index of the node directly after the node
5641        corresponding to 'index' in 'assignment'.
5642        """
5643        return _pywrapcp.RoutingModel_Next(self, assignment, index)
5644
5645    def IsVehicleUsed(self, assignment, vehicle):
5646        r""" Returns true if the route of 'vehicle' is non empty in 'assignment'."""
5647        return _pywrapcp.RoutingModel_IsVehicleUsed(self, assignment, vehicle)
5648
5649    def NextVar(self, index):
5650        r"""
5651        Returns the next variable of the node corresponding to index. Note that
5652        NextVar(index) == index is equivalent to ActiveVar(index) == 0.
5653        """
5654        return _pywrapcp.RoutingModel_NextVar(self, index)
5655
5656    def ActiveVar(self, index):
5657        r""" Returns the active variable of the node corresponding to index."""
5658        return _pywrapcp.RoutingModel_ActiveVar(self, index)
5659
5660    def ActiveVehicleVar(self, vehicle):
5661        r"""
5662        Returns the active variable of the vehicle. It will be equal to 1 iff the
5663        route of the vehicle is not empty, 0 otherwise.
5664        """
5665        return _pywrapcp.RoutingModel_ActiveVehicleVar(self, vehicle)
5666
5667    def VehicleRouteConsideredVar(self, vehicle):
5668        r"""
5669        Returns the variable specifying whether or not the given vehicle route is
5670        considered for costs and constraints. It will be equal to 1 iff the route
5671        of the vehicle is not empty OR vehicle_used_when_empty_[vehicle] is true.
5672        """
5673        return _pywrapcp.RoutingModel_VehicleRouteConsideredVar(self, vehicle)
5674
5675    def VehicleVar(self, index):
5676        r"""
5677        Returns the vehicle variable of the node corresponding to index. Note that
5678        VehicleVar(index) == -1 is equivalent to ActiveVar(index) == 0.
5679        """
5680        return _pywrapcp.RoutingModel_VehicleVar(self, index)
5681
5682    def ResourceVar(self, vehicle, resource_group):
5683        r"""
5684        Returns the resource variable for the given vehicle index in the given
5685        resource group. If a vehicle doesn't require a resource from the
5686        corresponding resource group, then ResourceVar(v, r_g) == -1.
5687        """
5688        return _pywrapcp.RoutingModel_ResourceVar(self, vehicle, resource_group)
5689
5690    def CostVar(self):
5691        r""" Returns the global cost variable which is being minimized."""
5692        return _pywrapcp.RoutingModel_CostVar(self)
5693
5694    def GetArcCostForVehicle(self, from_index, to_index, vehicle):
5695        r"""
5696        Returns the cost of the transit arc between two nodes for a given vehicle.
5697        Input are variable indices of node. This returns 0 if vehicle < 0.
5698        """
5699        return _pywrapcp.RoutingModel_GetArcCostForVehicle(self, from_index, to_index, vehicle)
5700
5701    def CostsAreHomogeneousAcrossVehicles(self):
5702        r""" Whether costs are homogeneous across all vehicles."""
5703        return _pywrapcp.RoutingModel_CostsAreHomogeneousAcrossVehicles(self)
5704
5705    def GetHomogeneousCost(self, from_index, to_index):
5706        r"""
5707        Returns the cost of the segment between two nodes supposing all vehicle
5708        costs are the same (returns the cost for the first vehicle otherwise).
5709        """
5710        return _pywrapcp.RoutingModel_GetHomogeneousCost(self, from_index, to_index)
5711
5712    def GetArcCostForFirstSolution(self, from_index, to_index):
5713        r"""
5714        Returns the cost of the arc in the context of the first solution strategy.
5715        This is typically a simplification of the actual cost; see the .cc.
5716        """
5717        return _pywrapcp.RoutingModel_GetArcCostForFirstSolution(self, from_index, to_index)
5718
5719    def GetArcCostForClass(self, from_index, to_index, cost_class_index):
5720        r"""
5721        Returns the cost of the segment between two nodes for a given cost
5722        class. Input are variable indices of nodes and the cost class.
5723        Unlike GetArcCostForVehicle(), if cost_class is kNoCost, then the
5724        returned cost won't necessarily be zero: only some of the components
5725        of the cost that depend on the cost class will be omited. See the code
5726        for details.
5727        """
5728        return _pywrapcp.RoutingModel_GetArcCostForClass(self, from_index, to_index, cost_class_index)
5729
5730    def GetCostClassIndexOfVehicle(self, vehicle):
5731        r""" Get the cost class index of the given vehicle."""
5732        return _pywrapcp.RoutingModel_GetCostClassIndexOfVehicle(self, vehicle)
5733
5734    def HasVehicleWithCostClassIndex(self, cost_class_index):
5735        r"""
5736        Returns true iff the model contains a vehicle with the given
5737        cost_class_index.
5738        """
5739        return _pywrapcp.RoutingModel_HasVehicleWithCostClassIndex(self, cost_class_index)
5740
5741    def GetCostClassesCount(self):
5742        r""" Returns the number of different cost classes in the model."""
5743        return _pywrapcp.RoutingModel_GetCostClassesCount(self)
5744
5745    def GetNonZeroCostClassesCount(self):
5746        r""" Ditto, minus the 'always zero', built-in cost class."""
5747        return _pywrapcp.RoutingModel_GetNonZeroCostClassesCount(self)
5748
5749    def GetVehicleClassIndexOfVehicle(self, vehicle):
5750        return _pywrapcp.RoutingModel_GetVehicleClassIndexOfVehicle(self, vehicle)
5751
5752    def GetVehicleOfClass(self, vehicle_class):
5753        r"""
5754        Returns a vehicle of the given vehicle class, and -1 if there are no
5755        vehicles for this class.
5756        """
5757        return _pywrapcp.RoutingModel_GetVehicleOfClass(self, vehicle_class)
5758
5759    def GetVehicleClassesCount(self):
5760        r""" Returns the number of different vehicle classes in the model."""
5761        return _pywrapcp.RoutingModel_GetVehicleClassesCount(self)
5762
5763    def GetSameVehicleIndicesOfIndex(self, node):
5764        r""" Returns variable indices of nodes constrained to be on the same route."""
5765        return _pywrapcp.RoutingModel_GetSameVehicleIndicesOfIndex(self, node)
5766
5767    def GetVehicleTypeContainer(self):
5768        return _pywrapcp.RoutingModel_GetVehicleTypeContainer(self)
5769
5770    def ArcIsMoreConstrainedThanArc(self, _from, to1, to2):
5771        r"""
5772        Returns whether the arc from->to1 is more constrained than from->to2,
5773        taking into account, in order:
5774        - whether the destination node isn't an end node
5775        - whether the destination node is mandatory
5776        - whether the destination node is bound to the same vehicle as the source
5777        - the "primary constrained" dimension (see SetPrimaryConstrainedDimension)
5778        It then breaks ties using, in order:
5779        - the arc cost (taking unperformed penalties into account)
5780        - the size of the vehicle vars of "to1" and "to2" (lowest size wins)
5781        - the value: the lowest value of the indices to1 and to2 wins.
5782        See the .cc for details.
5783        The more constrained arc is typically preferable when building a
5784        first solution. This method is intended to be used as a callback for the
5785        BestValueByComparisonSelector value selector.
5786        Args:
5787          from: the variable index of the source node
5788          to1: the variable index of the first candidate destination node.
5789          to2: the variable index of the second candidate destination node.
5790        """
5791        return _pywrapcp.RoutingModel_ArcIsMoreConstrainedThanArc(self, _from, to1, to2)
5792
5793    def DebugOutputAssignment(self, solution_assignment, dimension_to_print):
5794        r"""
5795        Print some debugging information about an assignment, including the
5796        feasible intervals of the CumulVar for dimension "dimension_to_print"
5797        at each step of the routes.
5798        If "dimension_to_print" is omitted, all dimensions will be printed.
5799        """
5800        return _pywrapcp.RoutingModel_DebugOutputAssignment(self, solution_assignment, dimension_to_print)
5801
5802    def solver(self):
5803        r"""
5804        Returns a vector cumul_bounds, for which cumul_bounds[i][j] is a pair
5805        containing the minimum and maximum of the CumulVar of the jth node on
5806        route i.
5807        - cumul_bounds[i][j].first is the minimum.
5808        - cumul_bounds[i][j].second is the maximum.
5809        Returns the underlying constraint solver. Can be used to add extra
5810        constraints and/or modify search algorithms.
5811        """
5812        return _pywrapcp.RoutingModel_solver(self)
5813
5814    def CheckLimit(self, *args):
5815        r"""
5816        Returns true if the search limit has been crossed with the given time
5817        offset.
5818        """
5819        return _pywrapcp.RoutingModel_CheckLimit(self, *args)
5820
5821    def RemainingTime(self):
5822        r""" Returns the time left in the search limit."""
5823        return _pywrapcp.RoutingModel_RemainingTime(self)
5824
5825    def TimeBuffer(self):
5826        r""" Returns the time buffer to safely return a solution."""
5827        return _pywrapcp.RoutingModel_TimeBuffer(self)
5828
5829    def nodes(self):
5830        r"""
5831        Sizes and indices
5832        Returns the number of nodes in the model.
5833        """
5834        return _pywrapcp.RoutingModel_nodes(self)
5835
5836    def vehicles(self):
5837        r""" Returns the number of vehicle routes in the model."""
5838        return _pywrapcp.RoutingModel_vehicles(self)
5839
5840    def Size(self):
5841        r""" Returns the number of next variables in the model."""
5842        return _pywrapcp.RoutingModel_Size(self)
5843
5844    def GetNumberOfDecisionsInFirstSolution(self, search_parameters):
5845        r"""
5846        Returns statistics on first solution search, number of decisions sent to
5847        filters, number of decisions rejected by filters.
5848        """
5849        return _pywrapcp.RoutingModel_GetNumberOfDecisionsInFirstSolution(self, search_parameters)
5850
5851    def GetNumberOfRejectsInFirstSolution(self, search_parameters):
5852        return _pywrapcp.RoutingModel_GetNumberOfRejectsInFirstSolution(self, search_parameters)
5853
5854    def GetAutomaticFirstSolutionStrategy(self):
5855        r""" Returns the automatic first solution strategy selected."""
5856        return _pywrapcp.RoutingModel_GetAutomaticFirstSolutionStrategy(self)
5857
5858    def IsMatchingModel(self):
5859        r""" Returns true if a vehicle/node matching problem is detected."""
5860        return _pywrapcp.RoutingModel_IsMatchingModel(self)
5861
5862    def AreRoutesInterdependent(self, parameters):
5863        r"""
5864        Returns true if routes are interdependent. This means that any
5865        modification to a route might impact another.
5866        """
5867        return _pywrapcp.RoutingModel_AreRoutesInterdependent(self, parameters)
5868
5869    def MakeGuidedSlackFinalizer(self, dimension, initializer):
5870        r"""
5871        The next few members are in the public section only for testing purposes.
5872
5873        MakeGuidedSlackFinalizer creates a DecisionBuilder for the slacks of a
5874        dimension using a callback to choose which values to start with.
5875        The finalizer works only when all next variables in the model have
5876        been fixed. It has the following two characteristics:
5877        1. It follows the routes defined by the nexts variables when choosing a
5878           variable to make a decision on.
5879        2. When it comes to choose a value for the slack of node i, the decision
5880           builder first calls the callback with argument i, and supposingly the
5881           returned value is x it creates decisions slack[i] = x, slack[i] = x +
5882           1, slack[i] = x - 1, slack[i] = x + 2, etc.
5883        """
5884        return _pywrapcp.RoutingModel_MakeGuidedSlackFinalizer(self, dimension, initializer)
5885
5886    def MakeSelfDependentDimensionFinalizer(self, dimension):
5887        r"""
5888        MakeSelfDependentDimensionFinalizer is a finalizer for the slacks of a
5889        self-dependent dimension. It makes an extensive use of the caches of the
5890        state dependent transits.
5891        In detail, MakeSelfDependentDimensionFinalizer returns a composition of a
5892        local search decision builder with a greedy descent operator for the cumul
5893        of the start of each route and a guided slack finalizer. Provided there
5894        are no time windows and the maximum slacks are large enough, once the
5895        cumul of the start of route is fixed, the guided finalizer can find
5896        optimal values of the slacks for the rest of the route in time
5897        proportional to the length of the route. Therefore the composed finalizer
5898        generally works in time O(log(t)*n*m), where t is the latest possible
5899        departute time, n is the number of nodes in the network and m is the
5900        number of vehicles.
5901        """
5902        return _pywrapcp.RoutingModel_MakeSelfDependentDimensionFinalizer(self, dimension)
RoutingModel(*args)
4667    def __init__(self, *args):
4668        _pywrapcp.RoutingModel_swiginit(self, _pywrapcp.new_RoutingModel(*args))
thisown

The membership flag

ROUTING_NOT_SOLVED = 0

Problem not solved yet (before calling RoutingModel::Solve()).

ROUTING_SUCCESS = 1

Problem solved successfully after calling RoutingModel::Solve().

ROUTING_PARTIAL_SUCCESS_LOCAL_OPTIMUM_NOT_REACHED = 2

Problem solved successfully after calling RoutingModel::Solve(), except that a local optimum has not been reached. Leaving more time would allow improving the solution.

ROUTING_FAIL = 3

No solution found to the problem after calling RoutingModel::Solve().

ROUTING_FAIL_TIMEOUT = 4

Time limit reached before finding a solution with RoutingModel::Solve().

ROUTING_INVALID = 5

Model, model parameters or flags are not valid.

ROUTING_INFEASIBLE = 6

Problem proven to be infeasible.

PICKUP_AND_DELIVERY_NO_ORDER = 0

Any precedence is accepted.

PICKUP_AND_DELIVERY_LIFO = 1

Deliveries must be performed in reverse order of pickups.

PICKUP_AND_DELIVERY_FIFO = 2

Deliveries must be performed in the same order as pickups.

def RegisterUnaryTransitVector(self, values):
4671    def RegisterUnaryTransitVector(self, values):
4672        r""" Registers 'callback' and returns its index."""
4673        return _pywrapcp.RoutingModel_RegisterUnaryTransitVector(self, values)

Registers 'callback' and returns its index.

def RegisterUnaryTransitCallback(self, callback):
4675    def RegisterUnaryTransitCallback(self, callback):
4676        return _pywrapcp.RoutingModel_RegisterUnaryTransitCallback(self, callback)
def RegisterPositiveUnaryTransitCallback(self, callback):
4678    def RegisterPositiveUnaryTransitCallback(self, callback):
4679        return _pywrapcp.RoutingModel_RegisterPositiveUnaryTransitCallback(self, callback)
def RegisterTransitMatrix(self, values):
4681    def RegisterTransitMatrix(self, values):
4682        return _pywrapcp.RoutingModel_RegisterTransitMatrix(self, values)
def RegisterTransitCallback(self, callback):
4684    def RegisterTransitCallback(self, callback):
4685        return _pywrapcp.RoutingModel_RegisterTransitCallback(self, callback)
def RegisterPositiveTransitCallback(self, callback):
4687    def RegisterPositiveTransitCallback(self, callback):
4688        return _pywrapcp.RoutingModel_RegisterPositiveTransitCallback(self, callback)
def TransitCallback(self, callback_index):
4690    def TransitCallback(self, callback_index):
4691        return _pywrapcp.RoutingModel_TransitCallback(self, callback_index)
def UnaryTransitCallbackOrNull(self, callback_index):
4693    def UnaryTransitCallbackOrNull(self, callback_index):
4694        return _pywrapcp.RoutingModel_UnaryTransitCallbackOrNull(self, callback_index)
def AddDimension( self, evaluator_index, slack_max, capacity, fix_start_cumul_to_zero, name):
4696    def AddDimension(self, evaluator_index, slack_max, capacity, fix_start_cumul_to_zero, name):
4697        r"""
4698        Model creation
4699        Methods to add dimensions to routes; dimensions represent quantities
4700        accumulated at nodes along the routes. They represent quantities such as
4701        weights or volumes carried along the route, or distance or times.
4702        Quantities at a node are represented by "cumul" variables and the increase
4703        or decrease of quantities between nodes are represented by "transit"
4704        variables. These variables are linked as follows:
4705        if j == next(i), cumul(j) = cumul(i) + transit(i, j) + slack(i)
4706        where slack is a positive slack variable (can represent waiting times for
4707        a time dimension).
4708        Setting the value of fix_start_cumul_to_zero to true will force the
4709        "cumul" variable of the start node of all vehicles to be equal to 0.
4710        Creates a dimension where the transit variable is constrained to be
4711        equal to evaluator(i, next(i)); 'slack_max' is the upper bound of the
4712        slack variable and 'capacity' is the upper bound of the cumul variables.
4713        'name' is the name used to reference the dimension; this name is used to
4714        get cumul and transit variables from the routing model.
4715        Returns false if a dimension with the same name has already been created
4716        (and doesn't create the new dimension).
4717        Takes ownership of the callback 'evaluator'.
4718        """
4719        return _pywrapcp.RoutingModel_AddDimension(self, evaluator_index, slack_max, capacity, fix_start_cumul_to_zero, name)

Model creation Methods to add dimensions to routes; dimensions represent quantities accumulated at nodes along the routes. They represent quantities such as weights or volumes carried along the route, or distance or times. Quantities at a node are represented by "cumul" variables and the increase or decrease of quantities between nodes are represented by "transit" variables. These variables are linked as follows: if j == next(i), cumul(j) = cumul(i) + transit(i, j) + slack(i) where slack is a positive slack variable (can represent waiting times for a time dimension). Setting the value of fix_start_cumul_to_zero to true will force the "cumul" variable of the start node of all vehicles to be equal to 0. Creates a dimension where the transit variable is constrained to be equal to evaluator(i, next(i)); 'slack_max' is the upper bound of the slack variable and 'capacity' is the upper bound of the cumul variables. 'name' is the name used to reference the dimension; this name is used to get cumul and transit variables from the routing model. Returns false if a dimension with the same name has already been created (and doesn't create the new dimension). Takes ownership of the callback 'evaluator'.

def AddDimensionWithVehicleTransits( self, evaluator_indices, slack_max, capacity, fix_start_cumul_to_zero, name):
4721    def AddDimensionWithVehicleTransits(self, evaluator_indices, slack_max, capacity, fix_start_cumul_to_zero, name):
4722        return _pywrapcp.RoutingModel_AddDimensionWithVehicleTransits(self, evaluator_indices, slack_max, capacity, fix_start_cumul_to_zero, name)
def AddDimensionWithVehicleCapacity( self, evaluator_index, slack_max, vehicle_capacities, fix_start_cumul_to_zero, name):
4724    def AddDimensionWithVehicleCapacity(self, evaluator_index, slack_max, vehicle_capacities, fix_start_cumul_to_zero, name):
4725        return _pywrapcp.RoutingModel_AddDimensionWithVehicleCapacity(self, evaluator_index, slack_max, vehicle_capacities, fix_start_cumul_to_zero, name)
def AddDimensionWithVehicleTransitAndCapacity( self, evaluator_indices, slack_max, vehicle_capacities, fix_start_cumul_to_zero, name):
4727    def AddDimensionWithVehicleTransitAndCapacity(self, evaluator_indices, slack_max, vehicle_capacities, fix_start_cumul_to_zero, name):
4728        return _pywrapcp.RoutingModel_AddDimensionWithVehicleTransitAndCapacity(self, evaluator_indices, slack_max, vehicle_capacities, fix_start_cumul_to_zero, name)
def AddConstantDimensionWithSlack(self, value, capacity, slack_max, fix_start_cumul_to_zero, name):
4730    def AddConstantDimensionWithSlack(self, value, capacity, slack_max, fix_start_cumul_to_zero, name):
4731        r"""
4732        Creates a dimension where the transit variable is constrained to be
4733        equal to 'value'; 'capacity' is the upper bound of the cumul variables.
4734        'name' is the name used to reference the dimension; this name is used to
4735        get cumul and transit variables from the routing model.
4736        Returns a pair consisting of an index to the registered unary transit
4737        callback and a bool denoting whether the dimension has been created.
4738        It is false if a dimension with the same name has already been created
4739        (and doesn't create the new dimension but still register a new callback).
4740        """
4741        return _pywrapcp.RoutingModel_AddConstantDimensionWithSlack(self, value, capacity, slack_max, fix_start_cumul_to_zero, name)

Creates a dimension where the transit variable is constrained to be equal to 'value'; 'capacity' is the upper bound of the cumul variables. 'name' is the name used to reference the dimension; this name is used to get cumul and transit variables from the routing model. Returns a pair consisting of an index to the registered unary transit callback and a bool denoting whether the dimension has been created. It is false if a dimension with the same name has already been created (and doesn't create the new dimension but still register a new callback).

def AddConstantDimension(self, value, capacity, fix_start_cumul_to_zero, name):
4743    def AddConstantDimension(self, value, capacity, fix_start_cumul_to_zero, name):
4744        return _pywrapcp.RoutingModel_AddConstantDimension(self, value, capacity, fix_start_cumul_to_zero, name)
def AddVectorDimension(self, values, capacity, fix_start_cumul_to_zero, name):
4746    def AddVectorDimension(self, values, capacity, fix_start_cumul_to_zero, name):
4747        r"""
4748        Creates a dimension where the transit variable is constrained to be
4749        equal to 'values[i]' for node i; 'capacity' is the upper bound of
4750        the cumul variables. 'name' is the name used to reference the dimension;
4751        this name is used to get cumul and transit variables from the routing
4752        model.
4753        Returns a pair consisting of an index to the registered unary transit
4754        callback and a bool denoting whether the dimension has been created.
4755        It is false if a dimension with the same name has already been created
4756        (and doesn't create the new dimension but still register a new callback).
4757        """
4758        return _pywrapcp.RoutingModel_AddVectorDimension(self, values, capacity, fix_start_cumul_to_zero, name)

Creates a dimension where the transit variable is constrained to be equal to 'values[i]' for node i; 'capacity' is the upper bound of the cumul variables. 'name' is the name used to reference the dimension; this name is used to get cumul and transit variables from the routing model. Returns a pair consisting of an index to the registered unary transit callback and a bool denoting whether the dimension has been created. It is false if a dimension with the same name has already been created (and doesn't create the new dimension but still register a new callback).

def AddMatrixDimension(self, values, capacity, fix_start_cumul_to_zero, name):
4760    def AddMatrixDimension(self, values, capacity, fix_start_cumul_to_zero, name):
4761        r"""
4762        Creates a dimension where the transit variable is constrained to be
4763        equal to 'values[i][next(i)]' for node i; 'capacity' is the upper bound of
4764        the cumul variables. 'name' is the name used to reference the dimension;
4765        this name is used to get cumul and transit variables from the routing
4766        model.
4767        Returns a pair consisting of an index to the registered transit callback
4768        and a bool denoting whether the dimension has been created.
4769        It is false if a dimension with the same name has already been created
4770        (and doesn't create the new dimension but still register a new callback).
4771        """
4772        return _pywrapcp.RoutingModel_AddMatrixDimension(self, values, capacity, fix_start_cumul_to_zero, name)

Creates a dimension where the transit variable is constrained to be equal to 'values[i][next(i)]' for node i; 'capacity' is the upper bound of the cumul variables. 'name' is the name used to reference the dimension; this name is used to get cumul and transit variables from the routing model. Returns a pair consisting of an index to the registered transit callback and a bool denoting whether the dimension has been created. It is false if a dimension with the same name has already been created (and doesn't create the new dimension but still register a new callback).

def MakePathSpansAndTotalSlacks(self, dimension, spans, total_slacks):
4774    def MakePathSpansAndTotalSlacks(self, dimension, spans, total_slacks):
4775        r"""
4776        For every vehicle of the routing model:
4777        - if total_slacks[vehicle] is not nullptr, constrains it to be the sum of
4778          slacks on that vehicle, that is,
4779          dimension->CumulVar(end) - dimension->CumulVar(start) -
4780          sum_{node in path of vehicle} dimension->FixedTransitVar(node).
4781        - if spans[vehicle] is not nullptr, constrains it to be
4782          dimension->CumulVar(end) - dimension->CumulVar(start)
4783        This does stronger propagation than a decomposition, and takes breaks into
4784        account.
4785        """
4786        return _pywrapcp.RoutingModel_MakePathSpansAndTotalSlacks(self, dimension, spans, total_slacks)

For every vehicle of the routing model:

  • if total_slacks[vehicle] is not nullptr, constrains it to be the sum of slacks on that vehicle, that is, dimension->CumulVar(end) - dimension->CumulVar(start) - sum_{node in path of vehicle} dimension->FixedTransitVar(node).
  • if spans[vehicle] is not nullptr, constrains it to be dimension->CumulVar(end) - dimension->CumulVar(start) This does stronger propagation than a decomposition, and takes breaks into account.
def GetAllDimensionNames(self):
4788    def GetAllDimensionNames(self):
4789        r""" Outputs the names of all dimensions added to the routing engine."""
4790        return _pywrapcp.RoutingModel_GetAllDimensionNames(self)

Outputs the names of all dimensions added to the routing engine.

def GetDimensions(self):
4792    def GetDimensions(self):
4793        r""" Returns all dimensions of the model."""
4794        return _pywrapcp.RoutingModel_GetDimensions(self)

Returns all dimensions of the model.

def GetDimensionsWithSoftOrSpanCosts(self):
4796    def GetDimensionsWithSoftOrSpanCosts(self):
4797        r""" Returns dimensions with soft or vehicle span costs."""
4798        return _pywrapcp.RoutingModel_GetDimensionsWithSoftOrSpanCosts(self)

Returns dimensions with soft or vehicle span costs.

def GetDimensionsWithGlobalCumulOptimizers(self):
4800    def GetDimensionsWithGlobalCumulOptimizers(self):
4801        r""" Returns the dimensions which have [global|local]_dimension_optimizers_."""
4802        return _pywrapcp.RoutingModel_GetDimensionsWithGlobalCumulOptimizers(self)

Returns the dimensions which have [global|local]_dimension_optimizers_.

def GetDimensionsWithLocalCumulOptimizers(self):
4804    def GetDimensionsWithLocalCumulOptimizers(self):
4805        return _pywrapcp.RoutingModel_GetDimensionsWithLocalCumulOptimizers(self)
def HasGlobalCumulOptimizer(self, dimension):
4807    def HasGlobalCumulOptimizer(self, dimension):
4808        r""" Returns whether the given dimension has global/local cumul optimizers."""
4809        return _pywrapcp.RoutingModel_HasGlobalCumulOptimizer(self, dimension)

Returns whether the given dimension has global/local cumul optimizers.

def HasLocalCumulOptimizer(self, dimension):
4811    def HasLocalCumulOptimizer(self, dimension):
4812        return _pywrapcp.RoutingModel_HasLocalCumulOptimizer(self, dimension)
def GetMutableGlobalCumulLPOptimizer(self, dimension):
4814    def GetMutableGlobalCumulLPOptimizer(self, dimension):
4815        r"""
4816        Returns the global/local dimension cumul optimizer for a given dimension,
4817        or nullptr if there is none.
4818        """
4819        return _pywrapcp.RoutingModel_GetMutableGlobalCumulLPOptimizer(self, dimension)

Returns the global/local dimension cumul optimizer for a given dimension, or nullptr if there is none.

def GetMutableGlobalCumulMPOptimizer(self, dimension):
4821    def GetMutableGlobalCumulMPOptimizer(self, dimension):
4822        return _pywrapcp.RoutingModel_GetMutableGlobalCumulMPOptimizer(self, dimension)
def GetMutableLocalCumulLPOptimizer(self, dimension):
4824    def GetMutableLocalCumulLPOptimizer(self, dimension):
4825        return _pywrapcp.RoutingModel_GetMutableLocalCumulLPOptimizer(self, dimension)
def GetMutableLocalCumulMPOptimizer(self, dimension):
4827    def GetMutableLocalCumulMPOptimizer(self, dimension):
4828        return _pywrapcp.RoutingModel_GetMutableLocalCumulMPOptimizer(self, dimension)
def HasDimension(self, dimension_name):
4830    def HasDimension(self, dimension_name):
4831        r""" Returns true if a dimension exists for a given dimension name."""
4832        return _pywrapcp.RoutingModel_HasDimension(self, dimension_name)

Returns true if a dimension exists for a given dimension name.

def GetDimensionOrDie(self, dimension_name):
4834    def GetDimensionOrDie(self, dimension_name):
4835        r""" Returns a dimension from its name. Dies if the dimension does not exist."""
4836        return _pywrapcp.RoutingModel_GetDimensionOrDie(self, dimension_name)

Returns a dimension from its name. Dies if the dimension does not exist.

def GetMutableDimension(self, dimension_name):
4838    def GetMutableDimension(self, dimension_name):
4839        r"""
4840        Returns a dimension from its name. Returns nullptr if the dimension does
4841        not exist.
4842        """
4843        return _pywrapcp.RoutingModel_GetMutableDimension(self, dimension_name)

Returns a dimension from its name. Returns nullptr if the dimension does not exist.

def SetPrimaryConstrainedDimension(self, dimension_name):
4845    def SetPrimaryConstrainedDimension(self, dimension_name):
4846        r"""
4847        Set the given dimension as "primary constrained". As of August 2013, this
4848        is only used by ArcIsMoreConstrainedThanArc().
4849        "dimension" must be the name of an existing dimension, or be empty, in
4850        which case there will not be a primary dimension after this call.
4851        """
4852        return _pywrapcp.RoutingModel_SetPrimaryConstrainedDimension(self, dimension_name)

Set the given dimension as "primary constrained". As of August 2013, this is only used by ArcIsMoreConstrainedThanArc(). "dimension" must be the name of an existing dimension, or be empty, in which case there will not be a primary dimension after this call.

def GetPrimaryConstrainedDimension(self):
4854    def GetPrimaryConstrainedDimension(self):
4855        r""" Get the primary constrained dimension, or an empty string if it is unset."""
4856        return _pywrapcp.RoutingModel_GetPrimaryConstrainedDimension(self)

Get the primary constrained dimension, or an empty string if it is unset.

def AddResourceGroup(self):
4858    def AddResourceGroup(self):
4859        r"""
4860        Adds a resource group to the routing model. Returns its index in
4861        resource_groups_.
4862        """
4863        return _pywrapcp.RoutingModel_AddResourceGroup(self)

Adds a resource group to the routing model. Returns its index in resource_groups_.

def GetResourceGroups(self):
4865    def GetResourceGroups(self):
4866        return _pywrapcp.RoutingModel_GetResourceGroups(self)
def GetResourceGroup(self, rg_index):
4868    def GetResourceGroup(self, rg_index):
4869        return _pywrapcp.RoutingModel_GetResourceGroup(self, rg_index)
def GetDimensionResourceGroupIndices(self, dimension):
4871    def GetDimensionResourceGroupIndices(self, dimension):
4872        r"""
4873        Returns the indices of resource groups for this dimension. This method can
4874        only be called after the model has been closed.
4875        """
4876        return _pywrapcp.RoutingModel_GetDimensionResourceGroupIndices(self, dimension)

Returns the indices of resource groups for this dimension. This method can only be called after the model has been closed.

def GetDimensionResourceGroupIndex(self, dimension):
4878    def GetDimensionResourceGroupIndex(self, dimension):
4879        r"""
4880        Returns the index of the resource group attached to the dimension.
4881        DCHECKS that there's exactly one resource group for this dimension.
4882        """
4883        return _pywrapcp.RoutingModel_GetDimensionResourceGroupIndex(self, dimension)

Returns the index of the resource group attached to the dimension. DCHECKS that there's exactly one resource group for this dimension.

def AddDisjunction(self, *args):
4885    def AddDisjunction(self, *args):
4886        r"""
4887        Adds a disjunction constraint on the indices: exactly 'max_cardinality' of
4888        the indices are active. Start and end indices of any vehicle cannot be
4889        part of a disjunction.
4890
4891        If a penalty is given, at most 'max_cardinality' of the indices can be
4892        active, and if less are active, 'penalty' is payed per inactive index.
4893        This is equivalent to adding the constraint:
4894            p + Sum(i)active[i] == max_cardinality
4895        where p is an integer variable, and the following cost to the cost
4896        function:
4897            p * penalty.
4898        'penalty' must be positive to make the disjunction optional; a negative
4899        penalty will force 'max_cardinality' indices of the disjunction to be
4900        performed, and therefore p == 0.
4901        Note: passing a vector with a single index will model an optional index
4902        with a penalty cost if it is not visited.
4903        """
4904        return _pywrapcp.RoutingModel_AddDisjunction(self, *args)

Adds a disjunction constraint on the indices: exactly 'max_cardinality' of the indices are active. Start and end indices of any vehicle cannot be part of a disjunction.

If a penalty is given, at most 'max_cardinality' of the indices can be active, and if less are active, 'penalty' is payed per inactive index.

This is equivalent to adding the constraint:

p + Sum(i)active[i] == max_cardinality

where p is an integer variable, and the following cost to the cost function: p * penalty. 'penalty' must be positive to make the disjunction optional; a negative penalty will force 'max_cardinality' indices of the disjunction to be performed, and therefore p == 0. Note: passing a vector with a single index will model an optional index with a penalty cost if it is not visited.

def GetDisjunctionIndices(self, index):
4906    def GetDisjunctionIndices(self, index):
4907        r""" Returns the indices of the disjunctions to which an index belongs."""
4908        return _pywrapcp.RoutingModel_GetDisjunctionIndices(self, index)

Returns the indices of the disjunctions to which an index belongs.

def GetDisjunctionPenalty(self, index):
4910    def GetDisjunctionPenalty(self, index):
4911        r""" Returns the penalty of the node disjunction of index 'index'."""
4912        return _pywrapcp.RoutingModel_GetDisjunctionPenalty(self, index)

Returns the penalty of the node disjunction of index 'index'.

def GetDisjunctionMaxCardinality(self, index):
4914    def GetDisjunctionMaxCardinality(self, index):
4915        r"""
4916        Returns the maximum number of possible active nodes of the node
4917        disjunction of index 'index'.
4918        """
4919        return _pywrapcp.RoutingModel_GetDisjunctionMaxCardinality(self, index)

Returns the maximum number of possible active nodes of the node disjunction of index 'index'.

def GetNumberOfDisjunctions(self):
4921    def GetNumberOfDisjunctions(self):
4922        r""" Returns the number of node disjunctions in the model."""
4923        return _pywrapcp.RoutingModel_GetNumberOfDisjunctions(self)

Returns the number of node disjunctions in the model.

def HasMandatoryDisjunctions(self):
4925    def HasMandatoryDisjunctions(self):
4926        r"""
4927        Returns true if the model contains mandatory disjunctions (ones with
4928        kNoPenalty as penalty).
4929        """
4930        return _pywrapcp.RoutingModel_HasMandatoryDisjunctions(self)

Returns true if the model contains mandatory disjunctions (ones with kNoPenalty as penalty).

def HasMaxCardinalityConstrainedDisjunctions(self):
4932    def HasMaxCardinalityConstrainedDisjunctions(self):
4933        r"""
4934        Returns true if the model contains at least one disjunction which is
4935        constrained by its max_cardinality.
4936        """
4937        return _pywrapcp.RoutingModel_HasMaxCardinalityConstrainedDisjunctions(self)

Returns true if the model contains at least one disjunction which is constrained by its max_cardinality.

def GetPerfectBinaryDisjunctions(self):
4939    def GetPerfectBinaryDisjunctions(self):
4940        r"""
4941        Returns the list of all perfect binary disjunctions, as pairs of variable
4942        indices: a disjunction is "perfect" when its variables do not appear in
4943        any other disjunction. Each pair is sorted (lowest variable index first),
4944        and the output vector is also sorted (lowest pairs first).
4945        """
4946        return _pywrapcp.RoutingModel_GetPerfectBinaryDisjunctions(self)

Returns the list of all perfect binary disjunctions, as pairs of variable indices: a disjunction is "perfect" when its variables do not appear in any other disjunction. Each pair is sorted (lowest variable index first), and the output vector is also sorted (lowest pairs first).

def IgnoreDisjunctionsAlreadyForcedToZero(self):
4948    def IgnoreDisjunctionsAlreadyForcedToZero(self):
4949        r"""
4950        SPECIAL: Makes the solver ignore all the disjunctions whose active
4951        variables are all trivially zero (i.e. Max() == 0), by setting their
4952        max_cardinality to 0.
4953        This can be useful when using the BaseBinaryDisjunctionNeighborhood
4954        operators, in the context of arc-based routing.
4955        """
4956        return _pywrapcp.RoutingModel_IgnoreDisjunctionsAlreadyForcedToZero(self)

SPECIAL: Makes the solver ignore all the disjunctions whose active variables are all trivially zero (i.e. Max() == 0), by setting their max_cardinality to 0. This can be useful when using the BaseBinaryDisjunctionNeighborhood operators, in the context of arc-based routing.

def AddSoftSameVehicleConstraint(self, indices, cost):
4958    def AddSoftSameVehicleConstraint(self, indices, cost):
4959        r"""
4960        Adds a soft constraint to force a set of variable indices to be on the
4961        same vehicle. If all nodes are not on the same vehicle, each extra vehicle
4962        used adds 'cost' to the cost function.
4963        """
4964        return _pywrapcp.RoutingModel_AddSoftSameVehicleConstraint(self, indices, cost)

Adds a soft constraint to force a set of variable indices to be on the same vehicle. If all nodes are not on the same vehicle, each extra vehicle used adds 'cost' to the cost function.

def SetAllowedVehiclesForIndex(self, vehicles, index):
4966    def SetAllowedVehiclesForIndex(self, vehicles, index):
4967        r"""
4968        Sets the vehicles which can visit a given node. If the node is in a
4969        disjunction, this will not prevent it from being unperformed.
4970        Specifying an empty vector of vehicles has no effect (all vehicles
4971        will be allowed to visit the node).
4972        """
4973        return _pywrapcp.RoutingModel_SetAllowedVehiclesForIndex(self, vehicles, index)

Sets the vehicles which can visit a given node. If the node is in a disjunction, this will not prevent it from being unperformed. Specifying an empty vector of vehicles has no effect (all vehicles will be allowed to visit the node).

def IsVehicleAllowedForIndex(self, vehicle, index):
4975    def IsVehicleAllowedForIndex(self, vehicle, index):
4976        r""" Returns true if a vehicle is allowed to visit a given node."""
4977        return _pywrapcp.RoutingModel_IsVehicleAllowedForIndex(self, vehicle, index)

Returns true if a vehicle is allowed to visit a given node.

def AddPickupAndDelivery(self, pickup, delivery):
4979    def AddPickupAndDelivery(self, pickup, delivery):
4980        r"""
4981        Notifies that index1 and index2 form a pair of nodes which should belong
4982        to the same route. This methods helps the search find better solutions,
4983        especially in the local search phase.
4984        It should be called each time you have an equality constraint linking
4985        the vehicle variables of two node (including for instance pickup and
4986        delivery problems):
4987            Solver* const solver = routing.solver();
4988            int64_t index1 = manager.NodeToIndex(node1);
4989            int64_t index2 = manager.NodeToIndex(node2);
4990            solver->AddConstraint(solver->MakeEquality(
4991                routing.VehicleVar(index1),
4992                routing.VehicleVar(index2)));
4993            routing.AddPickupAndDelivery(index1, index2);
4994        """
4995        return _pywrapcp.RoutingModel_AddPickupAndDelivery(self, pickup, delivery)

Notifies that index1 and index2 form a pair of nodes which should belong to the same route. This methods helps the search find better solutions, especially in the local search phase. It should be called each time you have an equality constraint linking the vehicle variables of two node (including for instance pickup and delivery problems): Solver* const solver = routing.solver(); int64_t index1 = manager.NodeToIndex(node1); int64_t index2 = manager.NodeToIndex(node2); solver->AddConstraint(solver->MakeEquality( routing.VehicleVar(index1), routing.VehicleVar(index2))); routing.AddPickupAndDelivery(index1, index2);

def AddPickupAndDeliverySets(self, pickup_disjunction, delivery_disjunction):
4997    def AddPickupAndDeliverySets(self, pickup_disjunction, delivery_disjunction):
4998        r"""
4999        Same as AddPickupAndDelivery but notifying that the performed node from
5000        the disjunction of index 'pickup_disjunction' is on the same route as the
5001        performed node from the disjunction of index 'delivery_disjunction'.
5002        """
5003        return _pywrapcp.RoutingModel_AddPickupAndDeliverySets(self, pickup_disjunction, delivery_disjunction)

Same as AddPickupAndDelivery but notifying that the performed node from the disjunction of index 'pickup_disjunction' is on the same route as the performed node from the disjunction of index 'delivery_disjunction'.

def GetPickupIndexPairs(self, node_index):
5005    def GetPickupIndexPairs(self, node_index):
5006        r"""
5007        Returns pairs for which the node is a pickup; the first element of each
5008        pair is the index in the pickup and delivery pairs list in which the
5009        pickup appears, the second element is its index in the pickups list.
5010        """
5011        return _pywrapcp.RoutingModel_GetPickupIndexPairs(self, node_index)

Returns pairs for which the node is a pickup; the first element of each pair is the index in the pickup and delivery pairs list in which the pickup appears, the second element is its index in the pickups list.

def GetDeliveryIndexPairs(self, node_index):
5013    def GetDeliveryIndexPairs(self, node_index):
5014        r""" Same as above for deliveries."""
5015        return _pywrapcp.RoutingModel_GetDeliveryIndexPairs(self, node_index)

Same as above for deliveries.

def SetPickupAndDeliveryPolicyOfAllVehicles(self, policy):
5017    def SetPickupAndDeliveryPolicyOfAllVehicles(self, policy):
5018        r"""
5019        Sets the Pickup and delivery policy of all vehicles. It is equivalent to
5020        calling SetPickupAndDeliveryPolicyOfVehicle on all vehicles.
5021        """
5022        return _pywrapcp.RoutingModel_SetPickupAndDeliveryPolicyOfAllVehicles(self, policy)

Sets the Pickup and delivery policy of all vehicles. It is equivalent to calling SetPickupAndDeliveryPolicyOfVehicle on all vehicles.

def SetPickupAndDeliveryPolicyOfVehicle(self, policy, vehicle):
5024    def SetPickupAndDeliveryPolicyOfVehicle(self, policy, vehicle):
5025        return _pywrapcp.RoutingModel_SetPickupAndDeliveryPolicyOfVehicle(self, policy, vehicle)
def GetPickupAndDeliveryPolicyOfVehicle(self, vehicle):
5027    def GetPickupAndDeliveryPolicyOfVehicle(self, vehicle):
5028        return _pywrapcp.RoutingModel_GetPickupAndDeliveryPolicyOfVehicle(self, vehicle)
def GetNumOfSingletonNodes(self):
5030    def GetNumOfSingletonNodes(self):
5031        r"""
5032        Returns the number of non-start/end nodes which do not appear in a
5033        pickup/delivery pair.
5034        """
5035        return _pywrapcp.RoutingModel_GetNumOfSingletonNodes(self)

Returns the number of non-start/end nodes which do not appear in a pickup/delivery pair.

TYPE_ADDED_TO_VEHICLE = 0

When visited, the number of types 'T' on the vehicle increases by one.

ADDED_TYPE_REMOVED_FROM_VEHICLE = 1

When visited, one instance of type 'T' previously added to the route (TYPE_ADDED_TO_VEHICLE), if any, is removed from the vehicle. If the type was not previously added to the route or all added instances have already been removed, this visit has no effect on the types.

TYPE_ON_VEHICLE_UP_TO_VISIT = 2

With the following policy, the visit enforces that type 'T' is considered on the route from its start until this node is visited.

TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED = 3

The visit doesn't have an impact on the number of types 'T' on the route, as it's (virtually) added and removed directly. This policy can be used for visits which are part of an incompatibility or requirement set without affecting the type count on the route.

def SetVisitType(self, index, type, type_policy):
5058    def SetVisitType(self, index, type, type_policy):
5059        return _pywrapcp.RoutingModel_SetVisitType(self, index, type, type_policy)
def GetVisitType(self, index):
5061    def GetVisitType(self, index):
5062        return _pywrapcp.RoutingModel_GetVisitType(self, index)
def GetSingleNodesOfType(self, type):
5064    def GetSingleNodesOfType(self, type):
5065        return _pywrapcp.RoutingModel_GetSingleNodesOfType(self, type)
def GetPairIndicesOfType(self, type):
5067    def GetPairIndicesOfType(self, type):
5068        return _pywrapcp.RoutingModel_GetPairIndicesOfType(self, type)
def GetVisitTypePolicy(self, index):
5070    def GetVisitTypePolicy(self, index):
5071        return _pywrapcp.RoutingModel_GetVisitTypePolicy(self, index)
def CloseVisitTypes(self):
5073    def CloseVisitTypes(self):
5074        r"""
5075        This function should be called once all node visit types have been set and
5076        prior to adding any incompatibilities/requirements.
5077        "close" types.
5078        """
5079        return _pywrapcp.RoutingModel_CloseVisitTypes(self)

This function should be called once all node visit types have been set and prior to adding any incompatibilities/requirements. "close" types.

def GetNumberOfVisitTypes(self):
5081    def GetNumberOfVisitTypes(self):
5082        return _pywrapcp.RoutingModel_GetNumberOfVisitTypes(self)
def AddHardTypeIncompatibility(self, type1, type2):
5084    def AddHardTypeIncompatibility(self, type1, type2):
5085        r"""
5086        Incompatibilities:
5087        Two nodes with "hard" incompatible types cannot share the same route at
5088        all, while with a "temporal" incompatibility they can't be on the same
5089        route at the same time.
5090        """
5091        return _pywrapcp.RoutingModel_AddHardTypeIncompatibility(self, type1, type2)

Incompatibilities: Two nodes with "hard" incompatible types cannot share the same route at all, while with a "temporal" incompatibility they can't be on the same route at the same time.

def AddTemporalTypeIncompatibility(self, type1, type2):
5093    def AddTemporalTypeIncompatibility(self, type1, type2):
5094        return _pywrapcp.RoutingModel_AddTemporalTypeIncompatibility(self, type1, type2)
def GetHardTypeIncompatibilitiesOfType(self, type):
5096    def GetHardTypeIncompatibilitiesOfType(self, type):
5097        r""" Returns visit types incompatible with a given type."""
5098        return _pywrapcp.RoutingModel_GetHardTypeIncompatibilitiesOfType(self, type)

Returns visit types incompatible with a given type.

def GetTemporalTypeIncompatibilitiesOfType(self, type):
5100    def GetTemporalTypeIncompatibilitiesOfType(self, type):
5101        return _pywrapcp.RoutingModel_GetTemporalTypeIncompatibilitiesOfType(self, type)
def HasHardTypeIncompatibilities(self):
5103    def HasHardTypeIncompatibilities(self):
5104        r"""
5105        Returns true iff any hard (resp. temporal) type incompatibilities have
5106        been added to the model.
5107        """
5108        return _pywrapcp.RoutingModel_HasHardTypeIncompatibilities(self)

Returns true iff any hard (resp. temporal) type incompatibilities have been added to the model.

def HasTemporalTypeIncompatibilities(self):
5110    def HasTemporalTypeIncompatibilities(self):
5111        return _pywrapcp.RoutingModel_HasTemporalTypeIncompatibilities(self)
def AddSameVehicleRequiredTypeAlternatives(self, dependent_type, required_type_alternatives):
5113    def AddSameVehicleRequiredTypeAlternatives(self, dependent_type, required_type_alternatives):
5114        r"""
5115        Requirements:
5116        NOTE: As of 2019-04, cycles in the requirement graph are not supported,
5117        and lead to the dependent nodes being skipped if possible (otherwise
5118        the model is considered infeasible).
5119        The following functions specify that "dependent_type" requires at least
5120        one of the types in "required_type_alternatives".
5121
5122        For same-vehicle requirements, a node of dependent type type_D requires at
5123        least one node of type type_R among the required alternatives on the same
5124        route.
5125        """
5126        return _pywrapcp.RoutingModel_AddSameVehicleRequiredTypeAlternatives(self, dependent_type, required_type_alternatives)

Requirements: NOTE: As of 2019-04, cycles in the requirement graph are not supported, and lead to the dependent nodes being skipped if possible (otherwise the model is considered infeasible). The following functions specify that "dependent_type" requires at least one of the types in "required_type_alternatives".

For same-vehicle requirements, a node of dependent type type_D requires at least one node of type type_R among the required alternatives on the same route.

def AddRequiredTypeAlternativesWhenAddingType(self, dependent_type, required_type_alternatives):
5128    def AddRequiredTypeAlternativesWhenAddingType(self, dependent_type, required_type_alternatives):
5129        r"""
5130        If type_D depends on type_R when adding type_D, any node_D of type_D and
5131        VisitTypePolicy TYPE_ADDED_TO_VEHICLE or
5132        TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED requires at least one type_R on its
5133        vehicle at the time node_D is visited.
5134        """
5135        return _pywrapcp.RoutingModel_AddRequiredTypeAlternativesWhenAddingType(self, dependent_type, required_type_alternatives)

If type_D depends on type_R when adding type_D, any node_D of type_D and VisitTypePolicy TYPE_ADDED_TO_VEHICLE or TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED requires at least one type_R on its vehicle at the time node_D is visited.

def AddRequiredTypeAlternativesWhenRemovingType(self, dependent_type, required_type_alternatives):
5137    def AddRequiredTypeAlternativesWhenRemovingType(self, dependent_type, required_type_alternatives):
5138        r"""
5139        The following requirements apply when visiting dependent nodes that remove
5140        their type from the route, i.e. type_R must be on the vehicle when type_D
5141        of VisitTypePolicy ADDED_TYPE_REMOVED_FROM_VEHICLE,
5142        TYPE_ON_VEHICLE_UP_TO_VISIT or TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED is
5143        visited.
5144        """
5145        return _pywrapcp.RoutingModel_AddRequiredTypeAlternativesWhenRemovingType(self, dependent_type, required_type_alternatives)

The following requirements apply when visiting dependent nodes that remove their type from the route, i.e. type_R must be on the vehicle when type_D of VisitTypePolicy ADDED_TYPE_REMOVED_FROM_VEHICLE, TYPE_ON_VEHICLE_UP_TO_VISIT or TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED is visited.

def GetSameVehicleRequiredTypeAlternativesOfType(self, type):
5147    def GetSameVehicleRequiredTypeAlternativesOfType(self, type):
5148        r"""
5149        Returns the set of same-vehicle requirement alternatives for the given
5150        type.
5151        """
5152        return _pywrapcp.RoutingModel_GetSameVehicleRequiredTypeAlternativesOfType(self, type)

Returns the set of same-vehicle requirement alternatives for the given type.

def GetRequiredTypeAlternativesWhenAddingType(self, type):
5154    def GetRequiredTypeAlternativesWhenAddingType(self, type):
5155        r""" Returns the set of requirement alternatives when adding the given type."""
5156        return _pywrapcp.RoutingModel_GetRequiredTypeAlternativesWhenAddingType(self, type)

Returns the set of requirement alternatives when adding the given type.

def GetRequiredTypeAlternativesWhenRemovingType(self, type):
5158    def GetRequiredTypeAlternativesWhenRemovingType(self, type):
5159        r""" Returns the set of requirement alternatives when removing the given type."""
5160        return _pywrapcp.RoutingModel_GetRequiredTypeAlternativesWhenRemovingType(self, type)

Returns the set of requirement alternatives when removing the given type.

def HasSameVehicleTypeRequirements(self):
5162    def HasSameVehicleTypeRequirements(self):
5163        r"""
5164        Returns true iff any same-route (resp. temporal) type requirements have
5165        been added to the model.
5166        """
5167        return _pywrapcp.RoutingModel_HasSameVehicleTypeRequirements(self)

Returns true iff any same-route (resp. temporal) type requirements have been added to the model.

def HasTemporalTypeRequirements(self):
5169    def HasTemporalTypeRequirements(self):
5170        return _pywrapcp.RoutingModel_HasTemporalTypeRequirements(self)
def HasTypeRegulations(self):
5172    def HasTypeRegulations(self):
5173        r"""
5174        Returns true iff the model has any incompatibilities or requirements set
5175        on node types.
5176        """
5177        return _pywrapcp.RoutingModel_HasTypeRegulations(self)

Returns true iff the model has any incompatibilities or requirements set on node types.

def UnperformedPenalty(self, var_index):
5179    def UnperformedPenalty(self, var_index):
5180        r"""
5181        Get the "unperformed" penalty of a node. This is only well defined if the
5182        node is only part of a single Disjunction, and that disjunction has a
5183        penalty. For forced active nodes returns max int64_t. In all other cases,
5184        this returns 0.
5185        """
5186        return _pywrapcp.RoutingModel_UnperformedPenalty(self, var_index)

Get the "unperformed" penalty of a node. This is only well defined if the node is only part of a single Disjunction, and that disjunction has a penalty. For forced active nodes returns max int64_t. In all other cases, this returns 0.

def UnperformedPenaltyOrValue(self, default_value, var_index):
5188    def UnperformedPenaltyOrValue(self, default_value, var_index):
5189        r"""
5190        Same as above except that it returns default_value instead of 0 when
5191        penalty is not well defined (default value is passed as first argument to
5192        simplify the usage of the method in a callback).
5193        """
5194        return _pywrapcp.RoutingModel_UnperformedPenaltyOrValue(self, default_value, var_index)

Same as above except that it returns default_value instead of 0 when penalty is not well defined (default value is passed as first argument to simplify the usage of the method in a callback).

def GetDepot(self):
5196    def GetDepot(self):
5197        r"""
5198        Returns the variable index of the first starting or ending node of all
5199        routes. If all routes start  and end at the same node (single depot), this
5200        is the node returned.
5201        """
5202        return _pywrapcp.RoutingModel_GetDepot(self)

Returns the variable index of the first starting or ending node of all routes. If all routes start and end at the same node (single depot), this is the node returned.

def SetMaximumNumberOfActiveVehicles(self, max_active_vehicles):
5204    def SetMaximumNumberOfActiveVehicles(self, max_active_vehicles):
5205        r"""
5206        Constrains the maximum number of active vehicles, aka the number of
5207        vehicles which do not have an empty route. For instance, this can be used
5208        to limit the number of routes in the case where there are fewer drivers
5209        than vehicles and that the fleet of vehicle is heterogeneous.
5210        """
5211        return _pywrapcp.RoutingModel_SetMaximumNumberOfActiveVehicles(self, max_active_vehicles)

Constrains the maximum number of active vehicles, aka the number of vehicles which do not have an empty route. For instance, this can be used to limit the number of routes in the case where there are fewer drivers than vehicles and that the fleet of vehicle is heterogeneous.

def GetMaximumNumberOfActiveVehicles(self):
5213    def GetMaximumNumberOfActiveVehicles(self):
5214        r""" Returns the maximum number of active vehicles."""
5215        return _pywrapcp.RoutingModel_GetMaximumNumberOfActiveVehicles(self)

Returns the maximum number of active vehicles.

def SetArcCostEvaluatorOfAllVehicles(self, evaluator_index):
5217    def SetArcCostEvaluatorOfAllVehicles(self, evaluator_index):
5218        r"""
5219        Sets the cost function of the model such that the cost of a segment of a
5220        route between node 'from' and 'to' is evaluator(from, to), whatever the
5221        route or vehicle performing the route.
5222        """
5223        return _pywrapcp.RoutingModel_SetArcCostEvaluatorOfAllVehicles(self, evaluator_index)

Sets the cost function of the model such that the cost of a segment of a route between node 'from' and 'to' is evaluator(from, to), whatever the route or vehicle performing the route.

def SetArcCostEvaluatorOfVehicle(self, evaluator_index, vehicle):
5225    def SetArcCostEvaluatorOfVehicle(self, evaluator_index, vehicle):
5226        r""" Sets the cost function for a given vehicle route."""
5227        return _pywrapcp.RoutingModel_SetArcCostEvaluatorOfVehicle(self, evaluator_index, vehicle)

Sets the cost function for a given vehicle route.

def SetFixedCostOfAllVehicles(self, cost):
5229    def SetFixedCostOfAllVehicles(self, cost):
5230        r"""
5231        Sets the fixed cost of all vehicle routes. It is equivalent to calling
5232        SetFixedCostOfVehicle on all vehicle routes.
5233        """
5234        return _pywrapcp.RoutingModel_SetFixedCostOfAllVehicles(self, cost)

Sets the fixed cost of all vehicle routes. It is equivalent to calling SetFixedCostOfVehicle on all vehicle routes.

def SetFixedCostOfVehicle(self, cost, vehicle):
5236    def SetFixedCostOfVehicle(self, cost, vehicle):
5237        r""" Sets the fixed cost of one vehicle route."""
5238        return _pywrapcp.RoutingModel_SetFixedCostOfVehicle(self, cost, vehicle)

Sets the fixed cost of one vehicle route.

def GetFixedCostOfVehicle(self, vehicle):
5240    def GetFixedCostOfVehicle(self, vehicle):
5241        r"""
5242        Returns the route fixed cost taken into account if the route of the
5243        vehicle is not empty, aka there's at least one node on the route other
5244        than the first and last nodes.
5245        """
5246        return _pywrapcp.RoutingModel_GetFixedCostOfVehicle(self, vehicle)

Returns the route fixed cost taken into account if the route of the vehicle is not empty, aka there's at least one node on the route other than the first and last nodes.

def SetAmortizedCostFactorsOfAllVehicles(self, linear_cost_factor, quadratic_cost_factor):
5248    def SetAmortizedCostFactorsOfAllVehicles(self, linear_cost_factor, quadratic_cost_factor):
5249        r"""
5250        The following methods set the linear and quadratic cost factors of
5251        vehicles (must be positive values). The default value of these parameters
5252        is zero for all vehicles.
5253
5254        When set, the cost_ of the model will contain terms aiming at reducing the
5255        number of vehicles used in the model, by adding the following to the
5256        objective for every vehicle v:
5257        INDICATOR(v used in the model) *
5258          [linear_cost_factor_of_vehicle_[v]
5259           - quadratic_cost_factor_of_vehicle_[v]*(square of length of route v)]
5260        i.e. for every used vehicle, we add the linear factor as fixed cost, and
5261        subtract the square of the route length multiplied by the quadratic
5262        factor. This second term aims at making the routes as dense as possible.
5263
5264        Sets the linear and quadratic cost factor of all vehicles.
5265        """
5266        return _pywrapcp.RoutingModel_SetAmortizedCostFactorsOfAllVehicles(self, linear_cost_factor, quadratic_cost_factor)

The following methods set the linear and quadratic cost factors of vehicles (must be positive values). The default value of these parameters is zero for all vehicles.

When set, the cost_ of the model will contain terms aiming at reducing the number of vehicles used in the model, by adding the following to the objective for every vehicle v: INDICATOR(v used in the model) * [linear_cost_factor_of_vehicle_[v]

  • quadratic_cost_factor_of_vehicle_[v]*(square of length of route v)] i.e. for every used vehicle, we add the linear factor as fixed cost, and subtract the square of the route length multiplied by the quadratic factor. This second term aims at making the routes as dense as possible.

Sets the linear and quadratic cost factor of all vehicles.

def SetAmortizedCostFactorsOfVehicle(self, linear_cost_factor, quadratic_cost_factor, vehicle):
5268    def SetAmortizedCostFactorsOfVehicle(self, linear_cost_factor, quadratic_cost_factor, vehicle):
5269        r""" Sets the linear and quadratic cost factor of the given vehicle."""
5270        return _pywrapcp.RoutingModel_SetAmortizedCostFactorsOfVehicle(self, linear_cost_factor, quadratic_cost_factor, vehicle)

Sets the linear and quadratic cost factor of the given vehicle.

def GetAmortizedLinearCostFactorOfVehicles(self):
5272    def GetAmortizedLinearCostFactorOfVehicles(self):
5273        return _pywrapcp.RoutingModel_GetAmortizedLinearCostFactorOfVehicles(self)
def GetAmortizedQuadraticCostFactorOfVehicles(self):
5275    def GetAmortizedQuadraticCostFactorOfVehicles(self):
5276        return _pywrapcp.RoutingModel_GetAmortizedQuadraticCostFactorOfVehicles(self)
def SetVehicleUsedWhenEmpty(self, is_used, vehicle):
5278    def SetVehicleUsedWhenEmpty(self, is_used, vehicle):
5279        return _pywrapcp.RoutingModel_SetVehicleUsedWhenEmpty(self, is_used, vehicle)
def IsVehicleUsedWhenEmpty(self, vehicle):
5281    def IsVehicleUsedWhenEmpty(self, vehicle):
5282        return _pywrapcp.RoutingModel_IsVehicleUsedWhenEmpty(self, vehicle)
def SetFirstSolutionEvaluator(self, evaluator):
5284    def SetFirstSolutionEvaluator(self, evaluator):
5285        r"""
5286        Gets/sets the evaluator used during the search. Only relevant when
5287        RoutingSearchParameters.first_solution_strategy = EVALUATOR_STRATEGY.
5288        Takes ownership of evaluator.
5289        """
5290        return _pywrapcp.RoutingModel_SetFirstSolutionEvaluator(self, evaluator)

Gets/sets the evaluator used during the search. Only relevant when RoutingSearchParameters.first_solution_strategy = EVALUATOR_STRATEGY. Takes ownership of evaluator.

def AddLocalSearchOperator(self, ls_operator):
5292    def AddLocalSearchOperator(self, ls_operator):
5293        r"""
5294        Adds a local search operator to the set of operators used to solve the
5295        vehicle routing problem.
5296        """
5297        return _pywrapcp.RoutingModel_AddLocalSearchOperator(self, ls_operator)

Adds a local search operator to the set of operators used to solve the vehicle routing problem.

def AddSearchMonitor(self, monitor):
5299    def AddSearchMonitor(self, monitor):
5300        r""" Adds a search monitor to the search used to solve the routing model."""
5301        return _pywrapcp.RoutingModel_AddSearchMonitor(self, monitor)

Adds a search monitor to the search used to solve the routing model.

def AddAtSolutionCallback(self, callback):
5303    def AddAtSolutionCallback(self, callback):
5304        r"""
5305        Adds a callback called each time a solution is found during the search.
5306        This is a shortcut to creating a monitor to call the callback on
5307        AtSolution() and adding it with AddSearchMonitor.
5308        """
5309        return _pywrapcp.RoutingModel_AddAtSolutionCallback(self, callback)

Adds a callback called each time a solution is found during the search. This is a shortcut to creating a monitor to call the callback on AtSolution() and adding it with AddSearchMonitor.

def AddVariableMinimizedByFinalizer(self, var):
5311    def AddVariableMinimizedByFinalizer(self, var):
5312        r"""
5313        Adds a variable to minimize in the solution finalizer. The solution
5314        finalizer is called each time a solution is found during the search and
5315        allows to instantiate secondary variables (such as dimension cumul
5316        variables).
5317        """
5318        return _pywrapcp.RoutingModel_AddVariableMinimizedByFinalizer(self, var)

Adds a variable to minimize in the solution finalizer. The solution finalizer is called each time a solution is found during the search and allows to instantiate secondary variables (such as dimension cumul variables).

def AddVariableMaximizedByFinalizer(self, var):
5320    def AddVariableMaximizedByFinalizer(self, var):
5321        r"""
5322        Adds a variable to maximize in the solution finalizer (see above for
5323        information on the solution finalizer).
5324        """
5325        return _pywrapcp.RoutingModel_AddVariableMaximizedByFinalizer(self, var)

Adds a variable to maximize in the solution finalizer (see above for information on the solution finalizer).

def AddWeightedVariableMinimizedByFinalizer(self, var, cost):
5327    def AddWeightedVariableMinimizedByFinalizer(self, var, cost):
5328        r"""
5329        Adds a variable to minimize in the solution finalizer, with a weighted
5330        priority: the higher the more priority it has.
5331        """
5332        return _pywrapcp.RoutingModel_AddWeightedVariableMinimizedByFinalizer(self, var, cost)

Adds a variable to minimize in the solution finalizer, with a weighted priority: the higher the more priority it has.

def AddWeightedVariableMaximizedByFinalizer(self, var, cost):
5334    def AddWeightedVariableMaximizedByFinalizer(self, var, cost):
5335        r"""
5336        Adds a variable to maximize in the solution finalizer, with a weighted
5337        priority: the higher the more priority it has.
5338        """
5339        return _pywrapcp.RoutingModel_AddWeightedVariableMaximizedByFinalizer(self, var, cost)

Adds a variable to maximize in the solution finalizer, with a weighted priority: the higher the more priority it has.

def AddVariableTargetToFinalizer(self, var, target):
5341    def AddVariableTargetToFinalizer(self, var, target):
5342        r"""
5343        Add a variable to set the closest possible to the target value in the
5344        solution finalizer.
5345        """
5346        return _pywrapcp.RoutingModel_AddVariableTargetToFinalizer(self, var, target)

Add a variable to set the closest possible to the target value in the solution finalizer.

def AddWeightedVariableTargetToFinalizer(self, var, target, cost):
5348    def AddWeightedVariableTargetToFinalizer(self, var, target, cost):
5349        r"""
5350        Same as above with a weighted priority: the higher the cost, the more
5351        priority it has to be set close to the target value.
5352        """
5353        return _pywrapcp.RoutingModel_AddWeightedVariableTargetToFinalizer(self, var, target, cost)

Same as above with a weighted priority: the higher the cost, the more priority it has to be set close to the target value.

def CloseModel(self):
5355    def CloseModel(self):
5356        r"""
5357        Closes the current routing model; after this method is called, no
5358        modification to the model can be done, but RoutesToAssignment becomes
5359        available. Note that CloseModel() is automatically called by Solve() and
5360        other methods that produce solution.
5361        This is equivalent to calling
5362        CloseModelWithParameters(DefaultRoutingSearchParameters()).
5363        """
5364        return _pywrapcp.RoutingModel_CloseModel(self)

Closes the current routing model; after this method is called, no modification to the model can be done, but RoutesToAssignment becomes available. Note that CloseModel() is automatically called by Solve() and other methods that produce solution. This is equivalent to calling CloseModelWithParameters(DefaultRoutingSearchParameters()).

def CloseModelWithParameters(self, search_parameters):
5366    def CloseModelWithParameters(self, search_parameters):
5367        r"""
5368        Same as above taking search parameters (as of 10/2015 some the parameters
5369        have to be set when closing the model).
5370        """
5371        return _pywrapcp.RoutingModel_CloseModelWithParameters(self, search_parameters)

Same as above taking search parameters (as of 10/2015 some the parameters have to be set when closing the model).

def Solve(self, assignment=None):
5373    def Solve(self, assignment=None):
5374        r"""
5375        Solves the current routing model; closes the current model.
5376        This is equivalent to calling
5377        SolveWithParameters(DefaultRoutingSearchParameters())
5378        or
5379        SolveFromAssignmentWithParameters(assignment,
5380                                          DefaultRoutingSearchParameters()).
5381        """
5382        return _pywrapcp.RoutingModel_Solve(self, assignment)

Solves the current routing model; closes the current model. This is equivalent to calling SolveWithParameters(DefaultRoutingSearchParameters()) or SolveFromAssignmentWithParameters(assignment, DefaultRoutingSearchParameters()).

def SolveWithParameters(self, search_parameters, solutions=None):
5384    def SolveWithParameters(self, search_parameters, solutions=None):
5385        r"""
5386        Solves the current routing model with the given parameters. If 'solutions'
5387        is specified, it will contain the k best solutions found during the search
5388        (from worst to best, including the one returned by this method), where k
5389        corresponds to the 'number_of_solutions_to_collect' in
5390        'search_parameters'. Note that the Assignment returned by the method and
5391        the ones in solutions are owned by the underlying solver and should not be
5392        deleted.
5393        """
5394        return _pywrapcp.RoutingModel_SolveWithParameters(self, search_parameters, solutions)

Solves the current routing model with the given parameters. If 'solutions' is specified, it will contain the k best solutions found during the search (from worst to best, including the one returned by this method), where k corresponds to the 'number_of_solutions_to_collect' in 'search_parameters'. Note that the Assignment returned by the method and the ones in solutions are owned by the underlying solver and should not be deleted.

def SolveFromAssignmentWithParameters(self, assignment, search_parameters, solutions=None):
5396    def SolveFromAssignmentWithParameters(self, assignment, search_parameters, solutions=None):
5397        r"""
5398        Same as above, except that if assignment is not null, it will be used as
5399        the initial solution.
5400        """
5401        return _pywrapcp.RoutingModel_SolveFromAssignmentWithParameters(self, assignment, search_parameters, solutions)

Same as above, except that if assignment is not null, it will be used as the initial solution.

def SolveFromAssignmentsWithParameters(self, assignments, search_parameters, solutions=None):
5403    def SolveFromAssignmentsWithParameters(self, assignments, search_parameters, solutions=None):
5404        r"""
5405        Same as above but will try all assignments in order as first solutions
5406        until one succeeds.
5407        """
5408        return _pywrapcp.RoutingModel_SolveFromAssignmentsWithParameters(self, assignments, search_parameters, solutions)

Same as above but will try all assignments in order as first solutions until one succeeds.

def SetAssignmentFromOtherModelAssignment(self, target_assignment, source_model, source_assignment):
5410    def SetAssignmentFromOtherModelAssignment(self, target_assignment, source_model, source_assignment):
5411        r"""
5412        Given a "source_model" and its "source_assignment", resets
5413        "target_assignment" with the IntVar variables (nexts_, and vehicle_vars_
5414        if costs aren't homogeneous across vehicles) of "this" model, with the
5415        values set according to those in "other_assignment".
5416        The objective_element of target_assignment is set to this->cost_.
5417        """
5418        return _pywrapcp.RoutingModel_SetAssignmentFromOtherModelAssignment(self, target_assignment, source_model, source_assignment)

Given a "source_model" and its "source_assignment", resets "target_assignment" with the IntVar variables (nexts_, and vehicle_vars_ if costs aren't homogeneous across vehicles) of "this" model, with the values set according to those in "other_assignment". The objective_element of target_assignment is set to this->cost_.

def ComputeLowerBound(self):
5420    def ComputeLowerBound(self):
5421        r"""
5422        Computes a lower bound to the routing problem solving a linear assignment
5423        problem. The routing model must be closed before calling this method.
5424        Note that problems with node disjunction constraints (including optional
5425        nodes) and non-homogenous costs are not supported (the method returns 0 in
5426        these cases).
5427        """
5428        return _pywrapcp.RoutingModel_ComputeLowerBound(self)

Computes a lower bound to the routing problem solving a linear assignment problem. The routing model must be closed before calling this method. Note that problems with node disjunction constraints (including optional nodes) and non-homogenous costs are not supported (the method returns 0 in these cases).

def status(self):
5430    def status(self):
5431        r""" Returns the current status of the routing model."""
5432        return _pywrapcp.RoutingModel_status(self)

Returns the current status of the routing model.

def enable_deep_serialization(self):
5434    def enable_deep_serialization(self):
5435        r""" Returns the value of the internal enable_deep_serialization_ parameter."""
5436        return _pywrapcp.RoutingModel_enable_deep_serialization(self)

Returns the value of the internal enable_deep_serialization_ parameter.

def ApplyLocks(self, locks):
5438    def ApplyLocks(self, locks):
5439        r"""
5440        Applies a lock chain to the next search. 'locks' represents an ordered
5441        vector of nodes representing a partial route which will be fixed during
5442        the next search; it will constrain next variables such that:
5443        next[locks[i]] == locks[i+1].
5444
5445        Returns the next variable at the end of the locked chain; this variable is
5446        not locked. An assignment containing the locks can be obtained by calling
5447        PreAssignment().
5448        """
5449        return _pywrapcp.RoutingModel_ApplyLocks(self, locks)

Applies a lock chain to the next search. 'locks' represents an ordered vector of nodes representing a partial route which will be fixed during the next search; it will constrain next variables such that: next[locks[i]] == locks[i+1].

Returns the next variable at the end of the locked chain; this variable is not locked. An assignment containing the locks can be obtained by calling PreAssignment().

def ApplyLocksToAllVehicles(self, locks, close_routes):
5451    def ApplyLocksToAllVehicles(self, locks, close_routes):
5452        r"""
5453        Applies lock chains to all vehicles to the next search, such that locks[p]
5454        is the lock chain for route p. Returns false if the locks do not contain
5455        valid routes; expects that the routes do not contain the depots,
5456        i.e. there are empty vectors in place of empty routes.
5457        If close_routes is set to true, adds the end nodes to the route of each
5458        vehicle and deactivates other nodes.
5459        An assignment containing the locks can be obtained by calling
5460        PreAssignment().
5461        """
5462        return _pywrapcp.RoutingModel_ApplyLocksToAllVehicles(self, locks, close_routes)

Applies lock chains to all vehicles to the next search, such that locks[p] is the lock chain for route p. Returns false if the locks do not contain valid routes; expects that the routes do not contain the depots, i.e. there are empty vectors in place of empty routes. If close_routes is set to true, adds the end nodes to the route of each vehicle and deactivates other nodes. An assignment containing the locks can be obtained by calling PreAssignment().

def PreAssignment(self):
5464    def PreAssignment(self):
5465        r"""
5466        Returns an assignment used to fix some of the variables of the problem.
5467        In practice, this assignment locks partial routes of the problem. This
5468        can be used in the context of locking the parts of the routes which have
5469        already been driven in online routing problems.
5470        """
5471        return _pywrapcp.RoutingModel_PreAssignment(self)

Returns an assignment used to fix some of the variables of the problem. In practice, this assignment locks partial routes of the problem. This can be used in the context of locking the parts of the routes which have already been driven in online routing problems.

def MutablePreAssignment(self):
5473    def MutablePreAssignment(self):
5474        return _pywrapcp.RoutingModel_MutablePreAssignment(self)
def WriteAssignment(self, file_name):
5476    def WriteAssignment(self, file_name):
5477        r"""
5478        Writes the current solution to a file containing an AssignmentProto.
5479        Returns false if the file cannot be opened or if there is no current
5480        solution.
5481        """
5482        return _pywrapcp.RoutingModel_WriteAssignment(self, file_name)

Writes the current solution to a file containing an AssignmentProto. Returns false if the file cannot be opened or if there is no current solution.

def ReadAssignment(self, file_name):
5484    def ReadAssignment(self, file_name):
5485        r"""
5486        Reads an assignment from a file and returns the current solution.
5487        Returns nullptr if the file cannot be opened or if the assignment is not
5488        valid.
5489        """
5490        return _pywrapcp.RoutingModel_ReadAssignment(self, file_name)

Reads an assignment from a file and returns the current solution. Returns nullptr if the file cannot be opened or if the assignment is not valid.

def RestoreAssignment(self, solution):
5492    def RestoreAssignment(self, solution):
5493        r"""
5494        Restores an assignment as a solution in the routing model and returns the
5495        new solution. Returns nullptr if the assignment is not valid.
5496        """
5497        return _pywrapcp.RoutingModel_RestoreAssignment(self, solution)

Restores an assignment as a solution in the routing model and returns the new solution. Returns nullptr if the assignment is not valid.

def ReadAssignmentFromRoutes(self, routes, ignore_inactive_indices):
5499    def ReadAssignmentFromRoutes(self, routes, ignore_inactive_indices):
5500        r"""
5501        Restores the routes as the current solution. Returns nullptr if the
5502        solution cannot be restored (routes do not contain a valid solution). Note
5503        that calling this method will run the solver to assign values to the
5504        dimension variables; this may take considerable amount of time, especially
5505        when using dimensions with slack.
5506        """
5507        return _pywrapcp.RoutingModel_ReadAssignmentFromRoutes(self, routes, ignore_inactive_indices)

Restores the routes as the current solution. Returns nullptr if the solution cannot be restored (routes do not contain a valid solution). Note that calling this method will run the solver to assign values to the dimension variables; this may take considerable amount of time, especially when using dimensions with slack.

def RoutesToAssignment(self, routes, ignore_inactive_indices, close_routes, assignment):
5509    def RoutesToAssignment(self, routes, ignore_inactive_indices, close_routes, assignment):
5510        r"""
5511        Fills an assignment from a specification of the routes of the
5512        vehicles. The routes are specified as lists of variable indices that
5513        appear on the routes of the vehicles. The indices of the outer vector in
5514        'routes' correspond to vehicles IDs, the inner vector contains the
5515        variable indices on the routes for the given vehicle. The inner vectors
5516        must not contain the start and end indices, as these are determined by the
5517        routing model.  Sets the value of NextVars in the assignment, adding the
5518        variables to the assignment if necessary. The method does not touch other
5519        variables in the assignment. The method can only be called after the model
5520        is closed.  With ignore_inactive_indices set to false, this method will
5521        fail (return nullptr) in case some of the route contain indices that are
5522        deactivated in the model; when set to true, these indices will be
5523        skipped.  Returns true if routes were successfully
5524        loaded. However, such assignment still might not be a valid
5525        solution to the routing problem due to more complex constraints;
5526        it is advisible to call solver()->CheckSolution() afterwards.
5527        """
5528        return _pywrapcp.RoutingModel_RoutesToAssignment(self, routes, ignore_inactive_indices, close_routes, assignment)

Fills an assignment from a specification of the routes of the vehicles. The routes are specified as lists of variable indices that appear on the routes of the vehicles. The indices of the outer vector in 'routes' correspond to vehicles IDs, the inner vector contains the variable indices on the routes for the given vehicle. The inner vectors must not contain the start and end indices, as these are determined by the routing model. Sets the value of NextVars in the assignment, adding the variables to the assignment if necessary. The method does not touch other variables in the assignment. The method can only be called after the model is closed. With ignore_inactive_indices set to false, this method will fail (return nullptr) in case some of the route contain indices that are deactivated in the model; when set to true, these indices will be skipped. Returns true if routes were successfully loaded. However, such assignment still might not be a valid solution to the routing problem due to more complex constraints; it is advisible to call solver()->CheckSolution() afterwards.

def AssignmentToRoutes(self, assignment, routes):
5530    def AssignmentToRoutes(self, assignment, routes):
5531        r"""
5532        Converts the solution in the given assignment to routes for all vehicles.
5533        Expects that assignment contains a valid solution (i.e. routes for all
5534        vehicles end with an end index for that vehicle).
5535        """
5536        return _pywrapcp.RoutingModel_AssignmentToRoutes(self, assignment, routes)

Converts the solution in the given assignment to routes for all vehicles. Expects that assignment contains a valid solution (i.e. routes for all vehicles end with an end index for that vehicle).

def CompactAssignment(self, assignment):
5538    def CompactAssignment(self, assignment):
5539        r"""
5540        Converts the solution in the given assignment to routes for all vehicles.
5541        If the returned vector is route_indices, route_indices[i][j] is the index
5542        for jth location visited on route i. Note that contrary to
5543        AssignmentToRoutes, the vectors do include start and end locations.
5544        Returns a compacted version of the given assignment, in which all vehicles
5545        with id lower or equal to some N have non-empty routes, and all vehicles
5546        with id greater than N have empty routes. Does not take ownership of the
5547        returned object.
5548        If found, the cost of the compact assignment is the same as in the
5549        original assignment and it preserves the values of 'active' variables.
5550        Returns nullptr if a compact assignment was not found.
5551        This method only works in homogenous mode, and it only swaps equivalent
5552        vehicles (vehicles with the same start and end nodes). When creating the
5553        compact assignment, the empty plan is replaced by the route assigned to
5554        the compatible vehicle with the highest id. Note that with more complex
5555        constraints on vehicle variables, this method might fail even if a compact
5556        solution exists.
5557        This method changes the vehicle and dimension variables as necessary.
5558        While compacting the solution, only basic checks on vehicle variables are
5559        performed; if one of these checks fails no attempts to repair it are made
5560        (instead, the method returns nullptr).
5561        """
5562        return _pywrapcp.RoutingModel_CompactAssignment(self, assignment)

Converts the solution in the given assignment to routes for all vehicles. If the returned vector is route_indices, route_indices[i][j] is the index for jth location visited on route i. Note that contrary to AssignmentToRoutes, the vectors do include start and end locations. Returns a compacted version of the given assignment, in which all vehicles with id lower or equal to some N have non-empty routes, and all vehicles with id greater than N have empty routes. Does not take ownership of the returned object. If found, the cost of the compact assignment is the same as in the original assignment and it preserves the values of 'active' variables. Returns nullptr if a compact assignment was not found. This method only works in homogenous mode, and it only swaps equivalent vehicles (vehicles with the same start and end nodes). When creating the compact assignment, the empty plan is replaced by the route assigned to the compatible vehicle with the highest id. Note that with more complex constraints on vehicle variables, this method might fail even if a compact solution exists. This method changes the vehicle and dimension variables as necessary. While compacting the solution, only basic checks on vehicle variables are performed; if one of these checks fails no attempts to repair it are made (instead, the method returns nullptr).

def CompactAndCheckAssignment(self, assignment):
5564    def CompactAndCheckAssignment(self, assignment):
5565        r"""
5566        Same as CompactAssignment() but also checks the validity of the final
5567        compact solution; if it is not valid, no attempts to repair it are made
5568        (instead, the method returns nullptr).
5569        """
5570        return _pywrapcp.RoutingModel_CompactAndCheckAssignment(self, assignment)

Same as CompactAssignment() but also checks the validity of the final compact solution; if it is not valid, no attempts to repair it are made (instead, the method returns nullptr).

def AddToAssignment(self, var):
5572    def AddToAssignment(self, var):
5573        r""" Adds an extra variable to the vehicle routing assignment."""
5574        return _pywrapcp.RoutingModel_AddToAssignment(self, var)

Adds an extra variable to the vehicle routing assignment.

def AddIntervalToAssignment(self, interval):
5576    def AddIntervalToAssignment(self, interval):
5577        return _pywrapcp.RoutingModel_AddIntervalToAssignment(self, interval)
def PackCumulsOfOptimizerDimensionsFromAssignment( self, original_assignment, duration_limit, time_limit_was_reached=None):
5579    def PackCumulsOfOptimizerDimensionsFromAssignment(self, original_assignment, duration_limit, time_limit_was_reached=None):
5580        r"""
5581        For every dimension in the model with an optimizer in
5582        local/global_dimension_optimizers_, this method tries to pack the cumul
5583        values of the dimension, such that:
5584        - The cumul costs (span costs, soft lower and upper bound costs, etc) are
5585          minimized.
5586        - The cumuls of the ends of the routes are minimized for this given
5587          minimal cumul cost.
5588        - Given these minimal end cumuls, the route start cumuls are maximized.
5589        Returns the assignment resulting from allocating these packed cumuls with
5590        the solver, and nullptr if these cumuls could not be set by the solver.
5591        """
5592        return _pywrapcp.RoutingModel_PackCumulsOfOptimizerDimensionsFromAssignment(self, original_assignment, duration_limit, time_limit_was_reached)

For every dimension in the model with an optimizer in local/global_dimension_optimizers_, this method tries to pack the cumul values of the dimension, such that:

  • The cumul costs (span costs, soft lower and upper bound costs, etc) are minimized.
  • The cumuls of the ends of the routes are minimized for this given minimal cumul cost.
  • Given these minimal end cumuls, the route start cumuls are maximized. Returns the assignment resulting from allocating these packed cumuls with the solver, and nullptr if these cumuls could not be set by the solver.
def GetOrCreateNodeNeighborsByCostClass(self, num_neighbors):
5594    def GetOrCreateNodeNeighborsByCostClass(self, num_neighbors):
5595        r"""
5596        Returns num_neighbors neighbors of all nodes for every cost class. The
5597        result is cached and is computed once.
5598        """
5599        return _pywrapcp.RoutingModel_GetOrCreateNodeNeighborsByCostClass(self, num_neighbors)

Returns num_neighbors neighbors of all nodes for every cost class. The result is cached and is computed once.

def AddLocalSearchFilter(self, filter):
5601    def AddLocalSearchFilter(self, filter):
5602        r"""
5603        Adds a custom local search filter to the list of filters used to speed up
5604        local search by pruning unfeasible variable assignments.
5605        Calling this method after the routing model has been closed (CloseModel()
5606        or Solve() has been called) has no effect.
5607        The routing model does not take ownership of the filter.
5608        """
5609        return _pywrapcp.RoutingModel_AddLocalSearchFilter(self, filter)

Adds a custom local search filter to the list of filters used to speed up local search by pruning unfeasible variable assignments. Calling this method after the routing model has been closed (CloseModel() or Solve() has been called) has no effect. The routing model does not take ownership of the filter.

def Start(self, vehicle):
5611    def Start(self, vehicle):
5612        r"""
5613        Model inspection.
5614        Returns the variable index of the starting node of a vehicle route.
5615        """
5616        return _pywrapcp.RoutingModel_Start(self, vehicle)

Model inspection. Returns the variable index of the starting node of a vehicle route.

def End(self, vehicle):
5618    def End(self, vehicle):
5619        r""" Returns the variable index of the ending node of a vehicle route."""
5620        return _pywrapcp.RoutingModel_End(self, vehicle)

Returns the variable index of the ending node of a vehicle route.

def IsStart(self, index):
5622    def IsStart(self, index):
5623        r""" Returns true if 'index' represents the first node of a route."""
5624        return _pywrapcp.RoutingModel_IsStart(self, index)

Returns true if 'index' represents the first node of a route.

def IsEnd(self, index):
5626    def IsEnd(self, index):
5627        r""" Returns true if 'index' represents the last node of a route."""
5628        return _pywrapcp.RoutingModel_IsEnd(self, index)

Returns true if 'index' represents the last node of a route.

def VehicleIndex(self, index):
5630    def VehicleIndex(self, index):
5631        r"""
5632        Returns the vehicle of the given start/end index, and -1 if the given
5633        index is not a vehicle start/end.
5634        """
5635        return _pywrapcp.RoutingModel_VehicleIndex(self, index)

Returns the vehicle of the given start/end index, and -1 if the given index is not a vehicle start/end.

def Next(self, assignment, index):
5637    def Next(self, assignment, index):
5638        r"""
5639        Assignment inspection
5640        Returns the variable index of the node directly after the node
5641        corresponding to 'index' in 'assignment'.
5642        """
5643        return _pywrapcp.RoutingModel_Next(self, assignment, index)

Assignment inspection Returns the variable index of the node directly after the node corresponding to 'index' in 'assignment'.

def IsVehicleUsed(self, assignment, vehicle):
5645    def IsVehicleUsed(self, assignment, vehicle):
5646        r""" Returns true if the route of 'vehicle' is non empty in 'assignment'."""
5647        return _pywrapcp.RoutingModel_IsVehicleUsed(self, assignment, vehicle)

Returns true if the route of 'vehicle' is non empty in 'assignment'.

def NextVar(self, index):
5649    def NextVar(self, index):
5650        r"""
5651        Returns the next variable of the node corresponding to index. Note that
5652        NextVar(index) == index is equivalent to ActiveVar(index) == 0.
5653        """
5654        return _pywrapcp.RoutingModel_NextVar(self, index)

Returns the next variable of the node corresponding to index. Note that NextVar(index) == index is equivalent to ActiveVar(index) == 0.

def ActiveVar(self, index):
5656    def ActiveVar(self, index):
5657        r""" Returns the active variable of the node corresponding to index."""
5658        return _pywrapcp.RoutingModel_ActiveVar(self, index)

Returns the active variable of the node corresponding to index.

def ActiveVehicleVar(self, vehicle):
5660    def ActiveVehicleVar(self, vehicle):
5661        r"""
5662        Returns the active variable of the vehicle. It will be equal to 1 iff the
5663        route of the vehicle is not empty, 0 otherwise.
5664        """
5665        return _pywrapcp.RoutingModel_ActiveVehicleVar(self, vehicle)

Returns the active variable of the vehicle. It will be equal to 1 iff the route of the vehicle is not empty, 0 otherwise.

def VehicleRouteConsideredVar(self, vehicle):
5667    def VehicleRouteConsideredVar(self, vehicle):
5668        r"""
5669        Returns the variable specifying whether or not the given vehicle route is
5670        considered for costs and constraints. It will be equal to 1 iff the route
5671        of the vehicle is not empty OR vehicle_used_when_empty_[vehicle] is true.
5672        """
5673        return _pywrapcp.RoutingModel_VehicleRouteConsideredVar(self, vehicle)

Returns the variable specifying whether or not the given vehicle route is considered for costs and constraints. It will be equal to 1 iff the route of the vehicle is not empty OR vehicle_used_when_empty_[vehicle] is true.

def VehicleVar(self, index):
5675    def VehicleVar(self, index):
5676        r"""
5677        Returns the vehicle variable of the node corresponding to index. Note that
5678        VehicleVar(index) == -1 is equivalent to ActiveVar(index) == 0.
5679        """
5680        return _pywrapcp.RoutingModel_VehicleVar(self, index)

Returns the vehicle variable of the node corresponding to index. Note that VehicleVar(index) == -1 is equivalent to ActiveVar(index) == 0.

def ResourceVar(self, vehicle, resource_group):
5682    def ResourceVar(self, vehicle, resource_group):
5683        r"""
5684        Returns the resource variable for the given vehicle index in the given
5685        resource group. If a vehicle doesn't require a resource from the
5686        corresponding resource group, then ResourceVar(v, r_g) == -1.
5687        """
5688        return _pywrapcp.RoutingModel_ResourceVar(self, vehicle, resource_group)

Returns the resource variable for the given vehicle index in the given resource group. If a vehicle doesn't require a resource from the corresponding resource group, then ResourceVar(v, r_g) == -1.

def CostVar(self):
5690    def CostVar(self):
5691        r""" Returns the global cost variable which is being minimized."""
5692        return _pywrapcp.RoutingModel_CostVar(self)

Returns the global cost variable which is being minimized.

def GetArcCostForVehicle(self, from_index, to_index, vehicle):
5694    def GetArcCostForVehicle(self, from_index, to_index, vehicle):
5695        r"""
5696        Returns the cost of the transit arc between two nodes for a given vehicle.
5697        Input are variable indices of node. This returns 0 if vehicle < 0.
5698        """
5699        return _pywrapcp.RoutingModel_GetArcCostForVehicle(self, from_index, to_index, vehicle)

Returns the cost of the transit arc between two nodes for a given vehicle. Input are variable indices of node. This returns 0 if vehicle < 0.

def CostsAreHomogeneousAcrossVehicles(self):
5701    def CostsAreHomogeneousAcrossVehicles(self):
5702        r""" Whether costs are homogeneous across all vehicles."""
5703        return _pywrapcp.RoutingModel_CostsAreHomogeneousAcrossVehicles(self)

Whether costs are homogeneous across all vehicles.

def GetHomogeneousCost(self, from_index, to_index):
5705    def GetHomogeneousCost(self, from_index, to_index):
5706        r"""
5707        Returns the cost of the segment between two nodes supposing all vehicle
5708        costs are the same (returns the cost for the first vehicle otherwise).
5709        """
5710        return _pywrapcp.RoutingModel_GetHomogeneousCost(self, from_index, to_index)

Returns the cost of the segment between two nodes supposing all vehicle costs are the same (returns the cost for the first vehicle otherwise).

def GetArcCostForFirstSolution(self, from_index, to_index):
5712    def GetArcCostForFirstSolution(self, from_index, to_index):
5713        r"""
5714        Returns the cost of the arc in the context of the first solution strategy.
5715        This is typically a simplification of the actual cost; see the .cc.
5716        """
5717        return _pywrapcp.RoutingModel_GetArcCostForFirstSolution(self, from_index, to_index)

Returns the cost of the arc in the context of the first solution strategy. This is typically a simplification of the actual cost; see the .cc.

def GetArcCostForClass(self, from_index, to_index, cost_class_index):
5719    def GetArcCostForClass(self, from_index, to_index, cost_class_index):
5720        r"""
5721        Returns the cost of the segment between two nodes for a given cost
5722        class. Input are variable indices of nodes and the cost class.
5723        Unlike GetArcCostForVehicle(), if cost_class is kNoCost, then the
5724        returned cost won't necessarily be zero: only some of the components
5725        of the cost that depend on the cost class will be omited. See the code
5726        for details.
5727        """
5728        return _pywrapcp.RoutingModel_GetArcCostForClass(self, from_index, to_index, cost_class_index)

Returns the cost of the segment between two nodes for a given cost class. Input are variable indices of nodes and the cost class. Unlike GetArcCostForVehicle(), if cost_class is kNoCost, then the returned cost won't necessarily be zero: only some of the components of the cost that depend on the cost class will be omited. See the code for details.

def GetCostClassIndexOfVehicle(self, vehicle):
5730    def GetCostClassIndexOfVehicle(self, vehicle):
5731        r""" Get the cost class index of the given vehicle."""
5732        return _pywrapcp.RoutingModel_GetCostClassIndexOfVehicle(self, vehicle)

Get the cost class index of the given vehicle.

def HasVehicleWithCostClassIndex(self, cost_class_index):
5734    def HasVehicleWithCostClassIndex(self, cost_class_index):
5735        r"""
5736        Returns true iff the model contains a vehicle with the given
5737        cost_class_index.
5738        """
5739        return _pywrapcp.RoutingModel_HasVehicleWithCostClassIndex(self, cost_class_index)

Returns true iff the model contains a vehicle with the given cost_class_index.

def GetCostClassesCount(self):
5741    def GetCostClassesCount(self):
5742        r""" Returns the number of different cost classes in the model."""
5743        return _pywrapcp.RoutingModel_GetCostClassesCount(self)

Returns the number of different cost classes in the model.

def GetNonZeroCostClassesCount(self):
5745    def GetNonZeroCostClassesCount(self):
5746        r""" Ditto, minus the 'always zero', built-in cost class."""
5747        return _pywrapcp.RoutingModel_GetNonZeroCostClassesCount(self)

Ditto, minus the 'always zero', built-in cost class.

def GetVehicleClassIndexOfVehicle(self, vehicle):
5749    def GetVehicleClassIndexOfVehicle(self, vehicle):
5750        return _pywrapcp.RoutingModel_GetVehicleClassIndexOfVehicle(self, vehicle)
def GetVehicleOfClass(self, vehicle_class):
5752    def GetVehicleOfClass(self, vehicle_class):
5753        r"""
5754        Returns a vehicle of the given vehicle class, and -1 if there are no
5755        vehicles for this class.
5756        """
5757        return _pywrapcp.RoutingModel_GetVehicleOfClass(self, vehicle_class)

Returns a vehicle of the given vehicle class, and -1 if there are no vehicles for this class.

def GetVehicleClassesCount(self):
5759    def GetVehicleClassesCount(self):
5760        r""" Returns the number of different vehicle classes in the model."""
5761        return _pywrapcp.RoutingModel_GetVehicleClassesCount(self)

Returns the number of different vehicle classes in the model.

def GetSameVehicleIndicesOfIndex(self, node):
5763    def GetSameVehicleIndicesOfIndex(self, node):
5764        r""" Returns variable indices of nodes constrained to be on the same route."""
5765        return _pywrapcp.RoutingModel_GetSameVehicleIndicesOfIndex(self, node)

Returns variable indices of nodes constrained to be on the same route.

def GetVehicleTypeContainer(self):
5767    def GetVehicleTypeContainer(self):
5768        return _pywrapcp.RoutingModel_GetVehicleTypeContainer(self)
def ArcIsMoreConstrainedThanArc(self, _from, to1, to2):
5770    def ArcIsMoreConstrainedThanArc(self, _from, to1, to2):
5771        r"""
5772        Returns whether the arc from->to1 is more constrained than from->to2,
5773        taking into account, in order:
5774        - whether the destination node isn't an end node
5775        - whether the destination node is mandatory
5776        - whether the destination node is bound to the same vehicle as the source
5777        - the "primary constrained" dimension (see SetPrimaryConstrainedDimension)
5778        It then breaks ties using, in order:
5779        - the arc cost (taking unperformed penalties into account)
5780        - the size of the vehicle vars of "to1" and "to2" (lowest size wins)
5781        - the value: the lowest value of the indices to1 and to2 wins.
5782        See the .cc for details.
5783        The more constrained arc is typically preferable when building a
5784        first solution. This method is intended to be used as a callback for the
5785        BestValueByComparisonSelector value selector.
5786        Args:
5787          from: the variable index of the source node
5788          to1: the variable index of the first candidate destination node.
5789          to2: the variable index of the second candidate destination node.
5790        """
5791        return _pywrapcp.RoutingModel_ArcIsMoreConstrainedThanArc(self, _from, to1, to2)

Returns whether the arc from->to1 is more constrained than from->to2, taking into account, in order:

  • whether the destination node isn't an end node
  • whether the destination node is mandatory
  • whether the destination node is bound to the same vehicle as the source
  • the "primary constrained" dimension (see SetPrimaryConstrainedDimension) It then breaks ties using, in order:
  • the arc cost (taking unperformed penalties into account)
  • the size of the vehicle vars of "to1" and "to2" (lowest size wins)
  • the value: the lowest value of the indices to1 and to2 wins. See the .cc for details. The more constrained arc is typically preferable when building a first solution. This method is intended to be used as a callback for the BestValueByComparisonSelector value selector.
Arguments:
  • from: the variable index of the source node
  • to1: the variable index of the first candidate destination node.
  • to2: the variable index of the second candidate destination node.
def DebugOutputAssignment(self, solution_assignment, dimension_to_print):
5793    def DebugOutputAssignment(self, solution_assignment, dimension_to_print):
5794        r"""
5795        Print some debugging information about an assignment, including the
5796        feasible intervals of the CumulVar for dimension "dimension_to_print"
5797        at each step of the routes.
5798        If "dimension_to_print" is omitted, all dimensions will be printed.
5799        """
5800        return _pywrapcp.RoutingModel_DebugOutputAssignment(self, solution_assignment, dimension_to_print)

Print some debugging information about an assignment, including the feasible intervals of the CumulVar for dimension "dimension_to_print" at each step of the routes. If "dimension_to_print" is omitted, all dimensions will be printed.

def solver(self):
5802    def solver(self):
5803        r"""
5804        Returns a vector cumul_bounds, for which cumul_bounds[i][j] is a pair
5805        containing the minimum and maximum of the CumulVar of the jth node on
5806        route i.
5807        - cumul_bounds[i][j].first is the minimum.
5808        - cumul_bounds[i][j].second is the maximum.
5809        Returns the underlying constraint solver. Can be used to add extra
5810        constraints and/or modify search algorithms.
5811        """
5812        return _pywrapcp.RoutingModel_solver(self)

Returns a vector cumul_bounds, for which cumul_bounds[i][j] is a pair containing the minimum and maximum of the CumulVar of the jth node on route i.

  • cumul_bounds[i][j].first is the minimum.
  • cumul_bounds[i][j].second is the maximum. Returns the underlying constraint solver. Can be used to add extra constraints and/or modify search algorithms.
def CheckLimit(self, *args):
5814    def CheckLimit(self, *args):
5815        r"""
5816        Returns true if the search limit has been crossed with the given time
5817        offset.
5818        """
5819        return _pywrapcp.RoutingModel_CheckLimit(self, *args)

Returns true if the search limit has been crossed with the given time offset.

def RemainingTime(self):
5821    def RemainingTime(self):
5822        r""" Returns the time left in the search limit."""
5823        return _pywrapcp.RoutingModel_RemainingTime(self)

Returns the time left in the search limit.

def TimeBuffer(self):
5825    def TimeBuffer(self):
5826        r""" Returns the time buffer to safely return a solution."""
5827        return _pywrapcp.RoutingModel_TimeBuffer(self)

Returns the time buffer to safely return a solution.

def nodes(self):
5829    def nodes(self):
5830        r"""
5831        Sizes and indices
5832        Returns the number of nodes in the model.
5833        """
5834        return _pywrapcp.RoutingModel_nodes(self)

Sizes and indices Returns the number of nodes in the model.

def vehicles(self):
5836    def vehicles(self):
5837        r""" Returns the number of vehicle routes in the model."""
5838        return _pywrapcp.RoutingModel_vehicles(self)

Returns the number of vehicle routes in the model.

def Size(self):
5840    def Size(self):
5841        r""" Returns the number of next variables in the model."""
5842        return _pywrapcp.RoutingModel_Size(self)

Returns the number of next variables in the model.

def GetNumberOfDecisionsInFirstSolution(self, search_parameters):
5844    def GetNumberOfDecisionsInFirstSolution(self, search_parameters):
5845        r"""
5846        Returns statistics on first solution search, number of decisions sent to
5847        filters, number of decisions rejected by filters.
5848        """
5849        return _pywrapcp.RoutingModel_GetNumberOfDecisionsInFirstSolution(self, search_parameters)

Returns statistics on first solution search, number of decisions sent to filters, number of decisions rejected by filters.

def GetNumberOfRejectsInFirstSolution(self, search_parameters):
5851    def GetNumberOfRejectsInFirstSolution(self, search_parameters):
5852        return _pywrapcp.RoutingModel_GetNumberOfRejectsInFirstSolution(self, search_parameters)
def GetAutomaticFirstSolutionStrategy(self):
5854    def GetAutomaticFirstSolutionStrategy(self):
5855        r""" Returns the automatic first solution strategy selected."""
5856        return _pywrapcp.RoutingModel_GetAutomaticFirstSolutionStrategy(self)

Returns the automatic first solution strategy selected.

def IsMatchingModel(self):
5858    def IsMatchingModel(self):
5859        r""" Returns true if a vehicle/node matching problem is detected."""
5860        return _pywrapcp.RoutingModel_IsMatchingModel(self)

Returns true if a vehicle/node matching problem is detected.

def AreRoutesInterdependent(self, parameters):
5862    def AreRoutesInterdependent(self, parameters):
5863        r"""
5864        Returns true if routes are interdependent. This means that any
5865        modification to a route might impact another.
5866        """
5867        return _pywrapcp.RoutingModel_AreRoutesInterdependent(self, parameters)

Returns true if routes are interdependent. This means that any modification to a route might impact another.

def MakeGuidedSlackFinalizer(self, dimension, initializer):
5869    def MakeGuidedSlackFinalizer(self, dimension, initializer):
5870        r"""
5871        The next few members are in the public section only for testing purposes.
5872
5873        MakeGuidedSlackFinalizer creates a DecisionBuilder for the slacks of a
5874        dimension using a callback to choose which values to start with.
5875        The finalizer works only when all next variables in the model have
5876        been fixed. It has the following two characteristics:
5877        1. It follows the routes defined by the nexts variables when choosing a
5878           variable to make a decision on.
5879        2. When it comes to choose a value for the slack of node i, the decision
5880           builder first calls the callback with argument i, and supposingly the
5881           returned value is x it creates decisions slack[i] = x, slack[i] = x +
5882           1, slack[i] = x - 1, slack[i] = x + 2, etc.
5883        """
5884        return _pywrapcp.RoutingModel_MakeGuidedSlackFinalizer(self, dimension, initializer)

The next few members are in the public section only for testing purposes.

MakeGuidedSlackFinalizer creates a DecisionBuilder for the slacks of a dimension using a callback to choose which values to start with. The finalizer works only when all next variables in the model have been fixed. It has the following two characteristics:

  1. It follows the routes defined by the nexts variables when choosing a variable to make a decision on.
  2. When it comes to choose a value for the slack of node i, the decision builder first calls the callback with argument i, and supposingly the returned value is x it creates decisions slack[i] = x, slack[i] = x + 1, slack[i] = x - 1, slack[i] = x + 2, etc.
def MakeSelfDependentDimensionFinalizer(self, dimension):
5886    def MakeSelfDependentDimensionFinalizer(self, dimension):
5887        r"""
5888        MakeSelfDependentDimensionFinalizer is a finalizer for the slacks of a
5889        self-dependent dimension. It makes an extensive use of the caches of the
5890        state dependent transits.
5891        In detail, MakeSelfDependentDimensionFinalizer returns a composition of a
5892        local search decision builder with a greedy descent operator for the cumul
5893        of the start of each route and a guided slack finalizer. Provided there
5894        are no time windows and the maximum slacks are large enough, once the
5895        cumul of the start of route is fixed, the guided finalizer can find
5896        optimal values of the slacks for the rest of the route in time
5897        proportional to the length of the route. Therefore the composed finalizer
5898        generally works in time O(log(t)*n*m), where t is the latest possible
5899        departute time, n is the number of nodes in the network and m is the
5900        number of vehicles.
5901        """
5902        return _pywrapcp.RoutingModel_MakeSelfDependentDimensionFinalizer(self, dimension)

MakeSelfDependentDimensionFinalizer is a finalizer for the slacks of a self-dependent dimension. It makes an extensive use of the caches of the state dependent transits. In detail, MakeSelfDependentDimensionFinalizer returns a composition of a local search decision builder with a greedy descent operator for the cumul of the start of each route and a guided slack finalizer. Provided there are no time windows and the maximum slacks are large enough, once the cumul of the start of route is fixed, the guided finalizer can find optimal values of the slacks for the rest of the route in time proportional to the length of the route. Therefore the composed finalizer generally works in time O(log(t)nm), where t is the latest possible departute time, n is the number of nodes in the network and m is the number of vehicles.

class RoutingModelVisitor(BaseObject):
5911class RoutingModelVisitor(BaseObject):
5912    r""" Routing model visitor."""
5913
5914    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
5915    __repr__ = _swig_repr
5916
5917    def __init__(self):
5918        _pywrapcp.RoutingModelVisitor_swiginit(self, _pywrapcp.new_RoutingModelVisitor())
5919    __swig_destroy__ = _pywrapcp.delete_RoutingModelVisitor

Routing model visitor.

RoutingModelVisitor()
5917    def __init__(self):
5918        _pywrapcp.RoutingModelVisitor_swiginit(self, _pywrapcp.new_RoutingModelVisitor())
thisown

The membership flag

Inherited Members
BaseObject
DebugString
class GlobalVehicleBreaksConstraint(Constraint):
5927class GlobalVehicleBreaksConstraint(Constraint):
5928    r"""
5929    GlobalVehicleBreaksConstraint ensures breaks constraints are enforced on
5930    all vehicles in the dimension passed to its constructor.
5931    It is intended to be used for dimensions representing time.
5932    A break constraint ensures break intervals fit on the route of a vehicle.
5933    For a given vehicle, it forces break intervals to be disjoint from visit
5934    intervals, where visit intervals start at CumulVar(node) and last for
5935    node_visit_transit[node]. Moreover, it ensures that there is enough time
5936    between two consecutive nodes of a route to do transit and vehicle breaks,
5937    i.e. if Next(nodeA) = nodeB, CumulVar(nodeA) = tA and CumulVar(nodeB) = tB,
5938    then SlackVar(nodeA) >= sum_{breaks [tA, tB)} duration(break).
5939    """
5940
5941    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
5942    __repr__ = _swig_repr
5943
5944    def __init__(self, dimension):
5945        _pywrapcp.GlobalVehicleBreaksConstraint_swiginit(self, _pywrapcp.new_GlobalVehicleBreaksConstraint(dimension))
5946
5947    def DebugString(self):
5948        return _pywrapcp.GlobalVehicleBreaksConstraint_DebugString(self)
5949
5950    def Post(self):
5951        return _pywrapcp.GlobalVehicleBreaksConstraint_Post(self)
5952
5953    def InitialPropagateWrapper(self):
5954        return _pywrapcp.GlobalVehicleBreaksConstraint_InitialPropagateWrapper(self)
5955    __swig_destroy__ = _pywrapcp.delete_GlobalVehicleBreaksConstraint

GlobalVehicleBreaksConstraint ensures breaks constraints are enforced on all vehicles in the dimension passed to its constructor. It is intended to be used for dimensions representing time. A break constraint ensures break intervals fit on the route of a vehicle. For a given vehicle, it forces break intervals to be disjoint from visit intervals, where visit intervals start at CumulVar(node) and last for node_visit_transit[node]. Moreover, it ensures that there is enough time between two consecutive nodes of a route to do transit and vehicle breaks, i.e. if Next(nodeA) = nodeB, CumulVar(nodeA) = tA and CumulVar(nodeB) = tB, then SlackVar(nodeA) >= sum_{breaks [tA, tB)} duration(break).

GlobalVehicleBreaksConstraint(dimension)
5944    def __init__(self, dimension):
5945        _pywrapcp.GlobalVehicleBreaksConstraint_swiginit(self, _pywrapcp.new_GlobalVehicleBreaksConstraint(dimension))
thisown

The membership flag

def DebugString(self):
5947    def DebugString(self):
5948        return _pywrapcp.GlobalVehicleBreaksConstraint_DebugString(self)
def Post(self):
5950    def Post(self):
5951        return _pywrapcp.GlobalVehicleBreaksConstraint_Post(self)

This method is called when the constraint is processed by the solver. Its main usage is to attach demons to variables.

def InitialPropagateWrapper(self):
5953    def InitialPropagateWrapper(self):
5954        return _pywrapcp.GlobalVehicleBreaksConstraint_InitialPropagateWrapper(self)

This method performs the initial propagation of the constraint. It is called just after the post.

class TypeRegulationsChecker:
5959class TypeRegulationsChecker(object):
5960    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
5961
5962    def __init__(self, *args, **kwargs):
5963        raise AttributeError("No constructor defined - class is abstract")
5964    __repr__ = _swig_repr
5965    __swig_destroy__ = _pywrapcp.delete_TypeRegulationsChecker
5966
5967    def CheckVehicle(self, vehicle, next_accessor):
5968        return _pywrapcp.TypeRegulationsChecker_CheckVehicle(self, vehicle, next_accessor)
TypeRegulationsChecker(*args, **kwargs)
5962    def __init__(self, *args, **kwargs):
5963        raise AttributeError("No constructor defined - class is abstract")
thisown

The membership flag

def CheckVehicle(self, vehicle, next_accessor):
5967    def CheckVehicle(self, vehicle, next_accessor):
5968        return _pywrapcp.TypeRegulationsChecker_CheckVehicle(self, vehicle, next_accessor)
class TypeIncompatibilityChecker(TypeRegulationsChecker):
5972class TypeIncompatibilityChecker(TypeRegulationsChecker):
5973    r""" Checker for type incompatibilities."""
5974
5975    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
5976    __repr__ = _swig_repr
5977
5978    def __init__(self, model, check_hard_incompatibilities):
5979        _pywrapcp.TypeIncompatibilityChecker_swiginit(self, _pywrapcp.new_TypeIncompatibilityChecker(model, check_hard_incompatibilities))
5980    __swig_destroy__ = _pywrapcp.delete_TypeIncompatibilityChecker

Checker for type incompatibilities.

TypeIncompatibilityChecker(model, check_hard_incompatibilities)
5978    def __init__(self, model, check_hard_incompatibilities):
5979        _pywrapcp.TypeIncompatibilityChecker_swiginit(self, _pywrapcp.new_TypeIncompatibilityChecker(model, check_hard_incompatibilities))
thisown

The membership flag

class TypeRequirementChecker(TypeRegulationsChecker):
5984class TypeRequirementChecker(TypeRegulationsChecker):
5985    r""" Checker for type requirements."""
5986
5987    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
5988    __repr__ = _swig_repr
5989
5990    def __init__(self, model):
5991        _pywrapcp.TypeRequirementChecker_swiginit(self, _pywrapcp.new_TypeRequirementChecker(model))
5992    __swig_destroy__ = _pywrapcp.delete_TypeRequirementChecker

Checker for type requirements.

TypeRequirementChecker(model)
5990    def __init__(self, model):
5991        _pywrapcp.TypeRequirementChecker_swiginit(self, _pywrapcp.new_TypeRequirementChecker(model))
thisown

The membership flag

class TypeRegulationsConstraint(Constraint):
5996class TypeRegulationsConstraint(Constraint):
5997    r"""
5998    The following constraint ensures that incompatibilities and requirements
5999    between types are respected.
6000
6001    It verifies both "hard" and "temporal" incompatibilities.
6002    Two nodes with hard incompatible types cannot be served by the same vehicle
6003    at all, while with a temporal incompatibility they can't be on the same
6004    route at the same time.
6005    The VisitTypePolicy of a node determines how visiting it impacts the type
6006    count on the route.
6007
6008    For example, for
6009    - three temporally incompatible types T1 T2 and T3
6010    - 2 pairs of nodes a1/r1 and a2/r2 of type T1 and T2 respectively, with
6011        - a1 and a2 of VisitTypePolicy TYPE_ADDED_TO_VEHICLE
6012        - r1 and r2 of policy ADDED_TYPE_REMOVED_FROM_VEHICLE
6013    - 3 nodes A, UV and AR of type T3, respectively with type policies
6014      TYPE_ADDED_TO_VEHICLE, TYPE_ON_VEHICLE_UP_TO_VISIT and
6015      TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED
6016    the configurations
6017    UV --> a1 --> r1 --> a2 --> r2,   a1 --> r1 --> a2 --> r2 --> A and
6018    a1 --> r1 --> AR --> a2 --> r2 are acceptable, whereas the configurations
6019    a1 --> a2 --> r1 --> ..., or A --> a1 --> r1 --> ..., or
6020    a1 --> r1 --> UV --> ... are not feasible.
6021
6022    It also verifies same-vehicle and temporal type requirements.
6023    A node of type T_d with a same-vehicle requirement for type T_r needs to be
6024    served by the same vehicle as a node of type T_r.
6025    Temporal requirements, on the other hand, can take effect either when the
6026    dependent type is being added to the route or when it's removed from it,
6027    which is determined by the dependent node's VisitTypePolicy.
6028    In the above example:
6029    - If T3 is required on the same vehicle as T1, A, AR or UV must be on the
6030      same vehicle as a1.
6031    - If T2 is required when adding T1, a2 must be visited *before* a1, and if
6032      r2 is also visited on the route, it must be *after* a1, i.e. T2 must be on
6033      the vehicle when a1 is visited:
6034      ... --> a2 --> ... --> a1 --> ... --> r2 --> ...
6035    - If T3 is required when removing T1, T3 needs to be on the vehicle when
6036      r1 is visited:
6037      ... --> A --> ... --> r1 --> ...   OR   ... --> r1 --> ... --> UV --> ...
6038    """
6039
6040    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
6041    __repr__ = _swig_repr
6042
6043    def __init__(self, model):
6044        _pywrapcp.TypeRegulationsConstraint_swiginit(self, _pywrapcp.new_TypeRegulationsConstraint(model))
6045
6046    def Post(self):
6047        return _pywrapcp.TypeRegulationsConstraint_Post(self)
6048
6049    def InitialPropagateWrapper(self):
6050        return _pywrapcp.TypeRegulationsConstraint_InitialPropagateWrapper(self)
6051    __swig_destroy__ = _pywrapcp.delete_TypeRegulationsConstraint

The following constraint ensures that incompatibilities and requirements between types are respected.

It verifies both "hard" and "temporal" incompatibilities. Two nodes with hard incompatible types cannot be served by the same vehicle at all, while with a temporal incompatibility they can't be on the same route at the same time. The VisitTypePolicy of a node determines how visiting it impacts the type count on the route.

For example, for

  • three temporally incompatible types T1 T2 and T3
  • 2 pairs of nodes a1/r1 and a2/r2 of type T1 and T2 respectively, with
    • a1 and a2 of VisitTypePolicy TYPE_ADDED_TO_VEHICLE
    • r1 and r2 of policy ADDED_TYPE_REMOVED_FROM_VEHICLE
  • 3 nodes A, UV and AR of type T3, respectively with type policies TYPE_ADDED_TO_VEHICLE, TYPE_ON_VEHICLE_UP_TO_VISIT and TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED the configurations UV --> a1 --> r1 --> a2 --> r2, a1 --> r1 --> a2 --> r2 --> A and a1 --> r1 --> AR --> a2 --> r2 are acceptable, whereas the configurations a1 --> a2 --> r1 --> ..., or A --> a1 --> r1 --> ..., or a1 --> r1 --> UV --> ... are not feasible.

It also verifies same-vehicle and temporal type requirements. A node of type T_d with a same-vehicle requirement for type T_r needs to be served by the same vehicle as a node of type T_r. Temporal requirements, on the other hand, can take effect either when the dependent type is being added to the route or when it's removed from it, which is determined by the dependent node's VisitTypePolicy. In the above example:

  • If T3 is required on the same vehicle as T1, A, AR or UV must be on the same vehicle as a1.
  • If T2 is required when adding T1, a2 must be visited before a1, and if r2 is also visited on the route, it must be after a1, i.e. T2 must be on the vehicle when a1 is visited: ... --> a2 --> ... --> a1 --> ... --> r2 --> ...
  • If T3 is required when removing T1, T3 needs to be on the vehicle when r1 is visited: ... --> A --> ... --> r1 --> ... OR ... --> r1 --> ... --> UV --> ...
TypeRegulationsConstraint(model)
6043    def __init__(self, model):
6044        _pywrapcp.TypeRegulationsConstraint_swiginit(self, _pywrapcp.new_TypeRegulationsConstraint(model))
thisown

The membership flag

def Post(self):
6046    def Post(self):
6047        return _pywrapcp.TypeRegulationsConstraint_Post(self)

This method is called when the constraint is processed by the solver. Its main usage is to attach demons to variables.

def InitialPropagateWrapper(self):
6049    def InitialPropagateWrapper(self):
6050        return _pywrapcp.TypeRegulationsConstraint_InitialPropagateWrapper(self)

This method performs the initial propagation of the constraint. It is called just after the post.

class BoundCost:
6055class BoundCost(object):
6056    r"""
6057    A structure meant to store soft bounds and associated violation constants.
6058    It is 'Simple' because it has one BoundCost per element,
6059    in contrast to 'Multiple'. Design notes:
6060    - it is meant to store model information to be shared through pointers,
6061      so it disallows copy and assign to avoid accidental duplication.
6062    - it keeps soft bounds as an array of structs to help cache,
6063      because code that uses such bounds typically use both bound and cost.
6064    - soft bounds are named pairs, prevents some mistakes.
6065    - using operator[] to access elements is not interesting,
6066      because the structure will be accessed through pointers, moreover having
6067      to type bound_cost reminds the user of the order if they do a copy
6068      assignment of the element.
6069    """
6070
6071    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
6072    __repr__ = _swig_repr
6073    bound = property(_pywrapcp.BoundCost_bound_get, _pywrapcp.BoundCost_bound_set)
6074    cost = property(_pywrapcp.BoundCost_cost_get, _pywrapcp.BoundCost_cost_set)
6075
6076    def __init__(self, *args):
6077        _pywrapcp.BoundCost_swiginit(self, _pywrapcp.new_BoundCost(*args))
6078    __swig_destroy__ = _pywrapcp.delete_BoundCost

A structure meant to store soft bounds and associated violation constants. It is 'Simple' because it has one BoundCost per element, in contrast to 'Multiple'. Design notes:

  • it is meant to store model information to be shared through pointers, so it disallows copy and assign to avoid accidental duplication.
  • it keeps soft bounds as an array of structs to help cache, because code that uses such bounds typically use both bound and cost.
  • soft bounds are named pairs, prevents some mistakes.
  • using operator[] to access elements is not interesting, because the structure will be accessed through pointers, moreover having to type bound_cost reminds the user of the order if they do a copy assignment of the element.
BoundCost(*args)
6076    def __init__(self, *args):
6077        _pywrapcp.BoundCost_swiginit(self, _pywrapcp.new_BoundCost(*args))
thisown

The membership flag

class SimpleBoundCosts:
6082class SimpleBoundCosts(object):
6083    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
6084    __repr__ = _swig_repr
6085
6086    def __init__(self, num_bounds, default_bound_cost):
6087        _pywrapcp.SimpleBoundCosts_swiginit(self, _pywrapcp.new_SimpleBoundCosts(num_bounds, default_bound_cost))
6088
6089    def bound_cost(self, element):
6090        return _pywrapcp.SimpleBoundCosts_bound_cost(self, element)
6091
6092    def size(self):
6093        return _pywrapcp.SimpleBoundCosts_size(self)
6094    __swig_destroy__ = _pywrapcp.delete_SimpleBoundCosts
SimpleBoundCosts(num_bounds, default_bound_cost)
6086    def __init__(self, num_bounds, default_bound_cost):
6087        _pywrapcp.SimpleBoundCosts_swiginit(self, _pywrapcp.new_SimpleBoundCosts(num_bounds, default_bound_cost))
thisown

The membership flag

def bound_cost(self, element):
6089    def bound_cost(self, element):
6090        return _pywrapcp.SimpleBoundCosts_bound_cost(self, element)
def size(self):
6092    def size(self):
6093        return _pywrapcp.SimpleBoundCosts_size(self)
class RoutingDimension:
6098class RoutingDimension(object):
6099    r"""
6100    Dimensions represent quantities accumulated at nodes along the routes. They
6101    represent quantities such as weights or volumes carried along the route, or
6102    distance or times.
6103
6104    Quantities at a node are represented by "cumul" variables and the increase
6105    or decrease of quantities between nodes are represented by "transit"
6106    variables. These variables are linked as follows:
6107
6108    if j == next(i),
6109    cumuls(j) = cumuls(i) + transits(i) + slacks(i) +
6110                state_dependent_transits(i)
6111
6112    where slack is a positive slack variable (can represent waiting times for
6113    a time dimension), and state_dependent_transits is a non-purely functional
6114    version of transits_. Favour transits over state_dependent_transits when
6115    possible, because purely functional callbacks allow more optimisations and
6116    make the model faster and easier to solve.
6117    for a given vehicle, it is passed as an external vector, it would be better
6118    to have this information here.
6119    """
6120
6121    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
6122
6123    def __init__(self, *args, **kwargs):
6124        raise AttributeError("No constructor defined")
6125    __repr__ = _swig_repr
6126    __swig_destroy__ = _pywrapcp.delete_RoutingDimension
6127
6128    def model(self):
6129        r""" Returns the model on which the dimension was created."""
6130        return _pywrapcp.RoutingDimension_model(self)
6131
6132    def GetTransitValue(self, from_index, to_index, vehicle):
6133        r"""
6134        Returns the transition value for a given pair of nodes (as var index);
6135        this value is the one taken by the corresponding transit variable when
6136        the 'next' variable for 'from_index' is bound to 'to_index'.
6137        """
6138        return _pywrapcp.RoutingDimension_GetTransitValue(self, from_index, to_index, vehicle)
6139
6140    def GetTransitValueFromClass(self, from_index, to_index, vehicle_class):
6141        r"""
6142        Same as above but taking a vehicle class of the dimension instead of a
6143        vehicle (the class of a vehicle can be obtained with vehicle_to_class()).
6144        """
6145        return _pywrapcp.RoutingDimension_GetTransitValueFromClass(self, from_index, to_index, vehicle_class)
6146
6147    def CumulVar(self, index):
6148        r"""
6149        Get the cumul, transit and slack variables for the given node (given as
6150        int64_t var index).
6151        """
6152        return _pywrapcp.RoutingDimension_CumulVar(self, index)
6153
6154    def TransitVar(self, index):
6155        return _pywrapcp.RoutingDimension_TransitVar(self, index)
6156
6157    def FixedTransitVar(self, index):
6158        return _pywrapcp.RoutingDimension_FixedTransitVar(self, index)
6159
6160    def SlackVar(self, index):
6161        return _pywrapcp.RoutingDimension_SlackVar(self, index)
6162
6163    def SetSpanUpperBoundForVehicle(self, upper_bound, vehicle):
6164        r"""
6165        Sets an upper bound on the dimension span on a given vehicle. This is the
6166        preferred way to limit the "length" of the route of a vehicle according to
6167        a dimension.
6168        """
6169        return _pywrapcp.RoutingDimension_SetSpanUpperBoundForVehicle(self, upper_bound, vehicle)
6170
6171    def SetSpanCostCoefficientForVehicle(self, coefficient, vehicle):
6172        r"""
6173        Sets a cost proportional to the dimension span on a given vehicle,
6174        or on all vehicles at once. "coefficient" must be nonnegative.
6175        This is handy to model costs proportional to idle time when the dimension
6176        represents time.
6177        The cost for a vehicle is
6178          span_cost = coefficient * (dimension end value - dimension start value).
6179        """
6180        return _pywrapcp.RoutingDimension_SetSpanCostCoefficientForVehicle(self, coefficient, vehicle)
6181
6182    def SetSpanCostCoefficientForAllVehicles(self, coefficient):
6183        return _pywrapcp.RoutingDimension_SetSpanCostCoefficientForAllVehicles(self, coefficient)
6184
6185    def SetGlobalSpanCostCoefficient(self, coefficient):
6186        r"""
6187        Sets a cost proportional to the *global* dimension span, that is the
6188        difference between the largest value of route end cumul variables and
6189        the smallest value of route start cumul variables.
6190        In other words:
6191        global_span_cost =
6192          coefficient * (Max(dimension end value) - Min(dimension start value)).
6193        """
6194        return _pywrapcp.RoutingDimension_SetGlobalSpanCostCoefficient(self, coefficient)
6195
6196    def SetCumulVarSoftUpperBound(self, index, upper_bound, coefficient):
6197        r"""
6198        Sets a soft upper bound to the cumul variable of a given variable index.
6199        If the value of the cumul variable is greater than the bound, a cost
6200        proportional to the difference between this value and the bound is added
6201        to the cost function of the model:
6202          cumulVar <= upper_bound -> cost = 0
6203           cumulVar > upper_bound -> cost = coefficient * (cumulVar - upper_bound)
6204        This is also handy to model tardiness costs when the dimension represents
6205        time.
6206        """
6207        return _pywrapcp.RoutingDimension_SetCumulVarSoftUpperBound(self, index, upper_bound, coefficient)
6208
6209    def HasCumulVarSoftUpperBound(self, index):
6210        r"""
6211        Returns true if a soft upper bound has been set for a given variable
6212        index.
6213        """
6214        return _pywrapcp.RoutingDimension_HasCumulVarSoftUpperBound(self, index)
6215
6216    def GetCumulVarSoftUpperBound(self, index):
6217        r"""
6218        Returns the soft upper bound of a cumul variable for a given variable
6219        index. The "hard" upper bound of the variable is returned if no soft upper
6220        bound has been set.
6221        """
6222        return _pywrapcp.RoutingDimension_GetCumulVarSoftUpperBound(self, index)
6223
6224    def GetCumulVarSoftUpperBoundCoefficient(self, index):
6225        r"""
6226        Returns the cost coefficient of the soft upper bound of a cumul variable
6227        for a given variable index. If no soft upper bound has been set, 0 is
6228        returned.
6229        """
6230        return _pywrapcp.RoutingDimension_GetCumulVarSoftUpperBoundCoefficient(self, index)
6231
6232    def SetCumulVarSoftLowerBound(self, index, lower_bound, coefficient):
6233        r"""
6234        Sets a soft lower bound to the cumul variable of a given variable index.
6235        If the value of the cumul variable is less than the bound, a cost
6236        proportional to the difference between this value and the bound is added
6237        to the cost function of the model:
6238          cumulVar > lower_bound -> cost = 0
6239          cumulVar <= lower_bound -> cost = coefficient * (lower_bound -
6240                      cumulVar).
6241        This is also handy to model earliness costs when the dimension represents
6242        time.
6243        """
6244        return _pywrapcp.RoutingDimension_SetCumulVarSoftLowerBound(self, index, lower_bound, coefficient)
6245
6246    def HasCumulVarSoftLowerBound(self, index):
6247        r"""
6248        Returns true if a soft lower bound has been set for a given variable
6249        index.
6250        """
6251        return _pywrapcp.RoutingDimension_HasCumulVarSoftLowerBound(self, index)
6252
6253    def GetCumulVarSoftLowerBound(self, index):
6254        r"""
6255        Returns the soft lower bound of a cumul variable for a given variable
6256        index. The "hard" lower bound of the variable is returned if no soft lower
6257        bound has been set.
6258        """
6259        return _pywrapcp.RoutingDimension_GetCumulVarSoftLowerBound(self, index)
6260
6261    def GetCumulVarSoftLowerBoundCoefficient(self, index):
6262        r"""
6263        Returns the cost coefficient of the soft lower bound of a cumul variable
6264        for a given variable index. If no soft lower bound has been set, 0 is
6265        returned.
6266        """
6267        return _pywrapcp.RoutingDimension_GetCumulVarSoftLowerBoundCoefficient(self, index)
6268
6269    def SetBreakIntervalsOfVehicle(self, breaks, vehicle, node_visit_transits):
6270        r"""
6271        Sets the breaks for a given vehicle. Breaks are represented by
6272        IntervalVars. They may interrupt transits between nodes and increase
6273        the value of corresponding slack variables.
6274        A break may take place before the start of a vehicle, after the end of
6275        a vehicle, or during a travel i -> j.
6276
6277        In that case, the interval [break.Start(), break.End()) must be a subset
6278        of [CumulVar(i) + pre_travel(i, j), CumulVar(j) - post_travel(i, j)). In
6279        other words, a break may not overlap any node n's visit, given by
6280        [CumulVar(n) - post_travel(_, n), CumulVar(n) + pre_travel(n, _)).
6281        This formula considers post_travel(_, start) and pre_travel(end, _) to be
6282        0; pre_travel will never be called on any (_, start) and post_travel will
6283        never we called on any (end, _). If pre_travel_evaluator or
6284        post_travel_evaluator is -1, it will be taken as a function that always
6285        returns 0.
6286        Deprecated, sets pre_travel(i, j) = node_visit_transit[i].
6287        """
6288        return _pywrapcp.RoutingDimension_SetBreakIntervalsOfVehicle(self, breaks, vehicle, node_visit_transits)
6289
6290    def SetBreakDistanceDurationOfVehicle(self, distance, duration, vehicle):
6291        r"""
6292        With breaks supposed to be consecutive, this forces the distance between
6293        breaks of size at least minimum_break_duration to be at most distance.
6294        This supposes that the time until route start and after route end are
6295        infinite breaks.
6296        """
6297        return _pywrapcp.RoutingDimension_SetBreakDistanceDurationOfVehicle(self, distance, duration, vehicle)
6298
6299    def InitializeBreaks(self):
6300        r"""
6301        Sets up vehicle_break_intervals_, vehicle_break_distance_duration_,
6302        pre_travel_evaluators and post_travel_evaluators.
6303        """
6304        return _pywrapcp.RoutingDimension_InitializeBreaks(self)
6305
6306    def HasBreakConstraints(self):
6307        r""" Returns true if any break interval or break distance was defined."""
6308        return _pywrapcp.RoutingDimension_HasBreakConstraints(self)
6309
6310    def GetPreTravelEvaluatorOfVehicle(self, vehicle):
6311        return _pywrapcp.RoutingDimension_GetPreTravelEvaluatorOfVehicle(self, vehicle)
6312
6313    def GetPostTravelEvaluatorOfVehicle(self, vehicle):
6314        return _pywrapcp.RoutingDimension_GetPostTravelEvaluatorOfVehicle(self, vehicle)
6315
6316    def base_dimension(self):
6317        r""" Returns the parent in the dependency tree if any or nullptr otherwise."""
6318        return _pywrapcp.RoutingDimension_base_dimension(self)
6319
6320    def ShortestTransitionSlack(self, node):
6321        r"""
6322        It makes sense to use the function only for self-dependent dimension.
6323        For such dimensions the value of the slack of a node determines the
6324        transition cost of the next transit. Provided that
6325          1. cumul[node] is fixed,
6326          2. next[node] and next[next[node]] (if exists) are fixed,
6327        the value of slack[node] for which cumul[next[node]] + transit[next[node]]
6328        is minimized can be found in O(1) using this function.
6329        """
6330        return _pywrapcp.RoutingDimension_ShortestTransitionSlack(self, node)
6331
6332    def name(self):
6333        r""" Returns the name of the dimension."""
6334        return _pywrapcp.RoutingDimension_name(self)
6335
6336    def SetPickupToDeliveryLimitFunctionForPair(self, limit_function, pair_index):
6337        return _pywrapcp.RoutingDimension_SetPickupToDeliveryLimitFunctionForPair(self, limit_function, pair_index)
6338
6339    def HasPickupToDeliveryLimits(self):
6340        return _pywrapcp.RoutingDimension_HasPickupToDeliveryLimits(self)
6341
6342    def AddNodePrecedence(self, first_node, second_node, offset):
6343        return _pywrapcp.RoutingDimension_AddNodePrecedence(self, first_node, second_node, offset)
6344
6345    def GetSpanUpperBoundForVehicle(self, vehicle):
6346        return _pywrapcp.RoutingDimension_GetSpanUpperBoundForVehicle(self, vehicle)
6347
6348    def GetSpanCostCoefficientForVehicle(self, vehicle):
6349        return _pywrapcp.RoutingDimension_GetSpanCostCoefficientForVehicle(self, vehicle)
6350
6351    def global_span_cost_coefficient(self):
6352        return _pywrapcp.RoutingDimension_global_span_cost_coefficient(self)
6353
6354    def GetGlobalOptimizerOffset(self):
6355        return _pywrapcp.RoutingDimension_GetGlobalOptimizerOffset(self)
6356
6357    def GetLocalOptimizerOffsetForVehicle(self, vehicle):
6358        return _pywrapcp.RoutingDimension_GetLocalOptimizerOffsetForVehicle(self, vehicle)
6359
6360    def SetSoftSpanUpperBoundForVehicle(self, bound_cost, vehicle):
6361        r"""
6362        If the span of vehicle on this dimension is larger than bound,
6363        the cost will be increased by cost * (span - bound).
6364        """
6365        return _pywrapcp.RoutingDimension_SetSoftSpanUpperBoundForVehicle(self, bound_cost, vehicle)
6366
6367    def HasSoftSpanUpperBounds(self):
6368        return _pywrapcp.RoutingDimension_HasSoftSpanUpperBounds(self)
6369
6370    def GetSoftSpanUpperBoundForVehicle(self, vehicle):
6371        return _pywrapcp.RoutingDimension_GetSoftSpanUpperBoundForVehicle(self, vehicle)
6372
6373    def SetQuadraticCostSoftSpanUpperBoundForVehicle(self, bound_cost, vehicle):
6374        r"""
6375        If the span of vehicle on this dimension is larger than bound,
6376        the cost will be increased by cost * (span - bound)^2.
6377        """
6378        return _pywrapcp.RoutingDimension_SetQuadraticCostSoftSpanUpperBoundForVehicle(self, bound_cost, vehicle)
6379
6380    def HasQuadraticCostSoftSpanUpperBounds(self):
6381        return _pywrapcp.RoutingDimension_HasQuadraticCostSoftSpanUpperBounds(self)
6382
6383    def GetQuadraticCostSoftSpanUpperBoundForVehicle(self, vehicle):
6384        return _pywrapcp.RoutingDimension_GetQuadraticCostSoftSpanUpperBoundForVehicle(self, vehicle)

Dimensions represent quantities accumulated at nodes along the routes. They represent quantities such as weights or volumes carried along the route, or distance or times.

Quantities at a node are represented by "cumul" variables and the increase or decrease of quantities between nodes are represented by "transit" variables. These variables are linked as follows:

if j == next(i), cumuls(j) = cumuls(i) + transits(i) + slacks(i) + state_dependent_transits(i)

where slack is a positive slack variable (can represent waiting times for a time dimension), and state_dependent_transits is a non-purely functional version of transits_. Favour transits over state_dependent_transits when possible, because purely functional callbacks allow more optimisations and make the model faster and easier to solve. for a given vehicle, it is passed as an external vector, it would be better to have this information here.

RoutingDimension(*args, **kwargs)
6123    def __init__(self, *args, **kwargs):
6124        raise AttributeError("No constructor defined")
thisown

The membership flag

def model(self):
6128    def model(self):
6129        r""" Returns the model on which the dimension was created."""
6130        return _pywrapcp.RoutingDimension_model(self)

Returns the model on which the dimension was created.

def GetTransitValue(self, from_index, to_index, vehicle):
6132    def GetTransitValue(self, from_index, to_index, vehicle):
6133        r"""
6134        Returns the transition value for a given pair of nodes (as var index);
6135        this value is the one taken by the corresponding transit variable when
6136        the 'next' variable for 'from_index' is bound to 'to_index'.
6137        """
6138        return _pywrapcp.RoutingDimension_GetTransitValue(self, from_index, to_index, vehicle)

Returns the transition value for a given pair of nodes (as var index); this value is the one taken by the corresponding transit variable when the 'next' variable for 'from_index' is bound to 'to_index'.

def GetTransitValueFromClass(self, from_index, to_index, vehicle_class):
6140    def GetTransitValueFromClass(self, from_index, to_index, vehicle_class):
6141        r"""
6142        Same as above but taking a vehicle class of the dimension instead of a
6143        vehicle (the class of a vehicle can be obtained with vehicle_to_class()).
6144        """
6145        return _pywrapcp.RoutingDimension_GetTransitValueFromClass(self, from_index, to_index, vehicle_class)

Same as above but taking a vehicle class of the dimension instead of a vehicle (the class of a vehicle can be obtained with vehicle_to_class()).

def CumulVar(self, index):
6147    def CumulVar(self, index):
6148        r"""
6149        Get the cumul, transit and slack variables for the given node (given as
6150        int64_t var index).
6151        """
6152        return _pywrapcp.RoutingDimension_CumulVar(self, index)

Get the cumul, transit and slack variables for the given node (given as int64_t var index).

def TransitVar(self, index):
6154    def TransitVar(self, index):
6155        return _pywrapcp.RoutingDimension_TransitVar(self, index)
def FixedTransitVar(self, index):
6157    def FixedTransitVar(self, index):
6158        return _pywrapcp.RoutingDimension_FixedTransitVar(self, index)
def SlackVar(self, index):
6160    def SlackVar(self, index):
6161        return _pywrapcp.RoutingDimension_SlackVar(self, index)
def SetSpanUpperBoundForVehicle(self, upper_bound, vehicle):
6163    def SetSpanUpperBoundForVehicle(self, upper_bound, vehicle):
6164        r"""
6165        Sets an upper bound on the dimension span on a given vehicle. This is the
6166        preferred way to limit the "length" of the route of a vehicle according to
6167        a dimension.
6168        """
6169        return _pywrapcp.RoutingDimension_SetSpanUpperBoundForVehicle(self, upper_bound, vehicle)

Sets an upper bound on the dimension span on a given vehicle. This is the preferred way to limit the "length" of the route of a vehicle according to a dimension.

def SetSpanCostCoefficientForVehicle(self, coefficient, vehicle):
6171    def SetSpanCostCoefficientForVehicle(self, coefficient, vehicle):
6172        r"""
6173        Sets a cost proportional to the dimension span on a given vehicle,
6174        or on all vehicles at once. "coefficient" must be nonnegative.
6175        This is handy to model costs proportional to idle time when the dimension
6176        represents time.
6177        The cost for a vehicle is
6178          span_cost = coefficient * (dimension end value - dimension start value).
6179        """
6180        return _pywrapcp.RoutingDimension_SetSpanCostCoefficientForVehicle(self, coefficient, vehicle)

Sets a cost proportional to the dimension span on a given vehicle, or on all vehicles at once. "coefficient" must be nonnegative. This is handy to model costs proportional to idle time when the dimension represents time. The cost for a vehicle is span_cost = coefficient * (dimension end value - dimension start value).

def SetSpanCostCoefficientForAllVehicles(self, coefficient):
6182    def SetSpanCostCoefficientForAllVehicles(self, coefficient):
6183        return _pywrapcp.RoutingDimension_SetSpanCostCoefficientForAllVehicles(self, coefficient)
def SetGlobalSpanCostCoefficient(self, coefficient):
6185    def SetGlobalSpanCostCoefficient(self, coefficient):
6186        r"""
6187        Sets a cost proportional to the *global* dimension span, that is the
6188        difference between the largest value of route end cumul variables and
6189        the smallest value of route start cumul variables.
6190        In other words:
6191        global_span_cost =
6192          coefficient * (Max(dimension end value) - Min(dimension start value)).
6193        """
6194        return _pywrapcp.RoutingDimension_SetGlobalSpanCostCoefficient(self, coefficient)

Sets a cost proportional to the global dimension span, that is the difference between the largest value of route end cumul variables and the smallest value of route start cumul variables. In other words: global_span_cost = coefficient * (Max(dimension end value) - Min(dimension start value)).

def SetCumulVarSoftUpperBound(self, index, upper_bound, coefficient):
6196    def SetCumulVarSoftUpperBound(self, index, upper_bound, coefficient):
6197        r"""
6198        Sets a soft upper bound to the cumul variable of a given variable index.
6199        If the value of the cumul variable is greater than the bound, a cost
6200        proportional to the difference between this value and the bound is added
6201        to the cost function of the model:
6202          cumulVar <= upper_bound -> cost = 0
6203           cumulVar > upper_bound -> cost = coefficient * (cumulVar - upper_bound)
6204        This is also handy to model tardiness costs when the dimension represents
6205        time.
6206        """
6207        return _pywrapcp.RoutingDimension_SetCumulVarSoftUpperBound(self, index, upper_bound, coefficient)

Sets a soft upper bound to the cumul variable of a given variable index. If the value of the cumul variable is greater than the bound, a cost proportional to the difference between this value and the bound is added to the cost function of the model: cumulVar <= upper_bound -> cost = 0 cumulVar > upper_bound -> cost = coefficient * (cumulVar - upper_bound) This is also handy to model tardiness costs when the dimension represents time.

def HasCumulVarSoftUpperBound(self, index):
6209    def HasCumulVarSoftUpperBound(self, index):
6210        r"""
6211        Returns true if a soft upper bound has been set for a given variable
6212        index.
6213        """
6214        return _pywrapcp.RoutingDimension_HasCumulVarSoftUpperBound(self, index)

Returns true if a soft upper bound has been set for a given variable index.

def GetCumulVarSoftUpperBound(self, index):
6216    def GetCumulVarSoftUpperBound(self, index):
6217        r"""
6218        Returns the soft upper bound of a cumul variable for a given variable
6219        index. The "hard" upper bound of the variable is returned if no soft upper
6220        bound has been set.
6221        """
6222        return _pywrapcp.RoutingDimension_GetCumulVarSoftUpperBound(self, index)

Returns the soft upper bound of a cumul variable for a given variable index. The "hard" upper bound of the variable is returned if no soft upper bound has been set.

def GetCumulVarSoftUpperBoundCoefficient(self, index):
6224    def GetCumulVarSoftUpperBoundCoefficient(self, index):
6225        r"""
6226        Returns the cost coefficient of the soft upper bound of a cumul variable
6227        for a given variable index. If no soft upper bound has been set, 0 is
6228        returned.
6229        """
6230        return _pywrapcp.RoutingDimension_GetCumulVarSoftUpperBoundCoefficient(self, index)

Returns the cost coefficient of the soft upper bound of a cumul variable for a given variable index. If no soft upper bound has been set, 0 is returned.

def SetCumulVarSoftLowerBound(self, index, lower_bound, coefficient):
6232    def SetCumulVarSoftLowerBound(self, index, lower_bound, coefficient):
6233        r"""
6234        Sets a soft lower bound to the cumul variable of a given variable index.
6235        If the value of the cumul variable is less than the bound, a cost
6236        proportional to the difference between this value and the bound is added
6237        to the cost function of the model:
6238          cumulVar > lower_bound -> cost = 0
6239          cumulVar <= lower_bound -> cost = coefficient * (lower_bound -
6240                      cumulVar).
6241        This is also handy to model earliness costs when the dimension represents
6242        time.
6243        """
6244        return _pywrapcp.RoutingDimension_SetCumulVarSoftLowerBound(self, index, lower_bound, coefficient)

Sets a soft lower bound to the cumul variable of a given variable index. If the value of the cumul variable is less than the bound, a cost proportional to the difference between this value and the bound is added to the cost function of the model: cumulVar > lower_bound -> cost = 0 cumulVar <= lower_bound -> cost = coefficient * (lower_bound - cumulVar). This is also handy to model earliness costs when the dimension represents time.

def HasCumulVarSoftLowerBound(self, index):
6246    def HasCumulVarSoftLowerBound(self, index):
6247        r"""
6248        Returns true if a soft lower bound has been set for a given variable
6249        index.
6250        """
6251        return _pywrapcp.RoutingDimension_HasCumulVarSoftLowerBound(self, index)

Returns true if a soft lower bound has been set for a given variable index.

def GetCumulVarSoftLowerBound(self, index):
6253    def GetCumulVarSoftLowerBound(self, index):
6254        r"""
6255        Returns the soft lower bound of a cumul variable for a given variable
6256        index. The "hard" lower bound of the variable is returned if no soft lower
6257        bound has been set.
6258        """
6259        return _pywrapcp.RoutingDimension_GetCumulVarSoftLowerBound(self, index)

Returns the soft lower bound of a cumul variable for a given variable index. The "hard" lower bound of the variable is returned if no soft lower bound has been set.

def GetCumulVarSoftLowerBoundCoefficient(self, index):
6261    def GetCumulVarSoftLowerBoundCoefficient(self, index):
6262        r"""
6263        Returns the cost coefficient of the soft lower bound of a cumul variable
6264        for a given variable index. If no soft lower bound has been set, 0 is
6265        returned.
6266        """
6267        return _pywrapcp.RoutingDimension_GetCumulVarSoftLowerBoundCoefficient(self, index)

Returns the cost coefficient of the soft lower bound of a cumul variable for a given variable index. If no soft lower bound has been set, 0 is returned.

def SetBreakIntervalsOfVehicle(self, breaks, vehicle, node_visit_transits):
6269    def SetBreakIntervalsOfVehicle(self, breaks, vehicle, node_visit_transits):
6270        r"""
6271        Sets the breaks for a given vehicle. Breaks are represented by
6272        IntervalVars. They may interrupt transits between nodes and increase
6273        the value of corresponding slack variables.
6274        A break may take place before the start of a vehicle, after the end of
6275        a vehicle, or during a travel i -> j.
6276
6277        In that case, the interval [break.Start(), break.End()) must be a subset
6278        of [CumulVar(i) + pre_travel(i, j), CumulVar(j) - post_travel(i, j)). In
6279        other words, a break may not overlap any node n's visit, given by
6280        [CumulVar(n) - post_travel(_, n), CumulVar(n) + pre_travel(n, _)).
6281        This formula considers post_travel(_, start) and pre_travel(end, _) to be
6282        0; pre_travel will never be called on any (_, start) and post_travel will
6283        never we called on any (end, _). If pre_travel_evaluator or
6284        post_travel_evaluator is -1, it will be taken as a function that always
6285        returns 0.
6286        Deprecated, sets pre_travel(i, j) = node_visit_transit[i].
6287        """
6288        return _pywrapcp.RoutingDimension_SetBreakIntervalsOfVehicle(self, breaks, vehicle, node_visit_transits)

Sets the breaks for a given vehicle. Breaks are represented by IntervalVars. They may interrupt transits between nodes and increase the value of corresponding slack variables. A break may take place before the start of a vehicle, after the end of a vehicle, or during a travel i -> j.

In that case, the interval [break.Start(), break.End()) must be a subset of [CumulVar(i) + pre_travel(i, j), CumulVar(j) - post_travel(i, j)). In other words, a break may not overlap any node n's visit, given by [CumulVar(n) - post_travel(_, n), CumulVar(n) + pre_travel(n, _)). This formula considers post_travel(_, start) and pre_travel(end, _) to be 0; pre_travel will never be called on any (_, start) and post_travel will never we called on any (end, _). If pre_travel_evaluator or post_travel_evaluator is -1, it will be taken as a function that always returns 0. Deprecated, sets pre_travel(i, j) = node_visit_transit[i].

def SetBreakDistanceDurationOfVehicle(self, distance, duration, vehicle):
6290    def SetBreakDistanceDurationOfVehicle(self, distance, duration, vehicle):
6291        r"""
6292        With breaks supposed to be consecutive, this forces the distance between
6293        breaks of size at least minimum_break_duration to be at most distance.
6294        This supposes that the time until route start and after route end are
6295        infinite breaks.
6296        """
6297        return _pywrapcp.RoutingDimension_SetBreakDistanceDurationOfVehicle(self, distance, duration, vehicle)

With breaks supposed to be consecutive, this forces the distance between breaks of size at least minimum_break_duration to be at most distance. This supposes that the time until route start and after route end are infinite breaks.

def InitializeBreaks(self):
6299    def InitializeBreaks(self):
6300        r"""
6301        Sets up vehicle_break_intervals_, vehicle_break_distance_duration_,
6302        pre_travel_evaluators and post_travel_evaluators.
6303        """
6304        return _pywrapcp.RoutingDimension_InitializeBreaks(self)

Sets up vehicle_break_intervals_, vehicle_break_distance_duration_, pre_travel_evaluators and post_travel_evaluators.

def HasBreakConstraints(self):
6306    def HasBreakConstraints(self):
6307        r""" Returns true if any break interval or break distance was defined."""
6308        return _pywrapcp.RoutingDimension_HasBreakConstraints(self)

Returns true if any break interval or break distance was defined.

def GetPreTravelEvaluatorOfVehicle(self, vehicle):
6310    def GetPreTravelEvaluatorOfVehicle(self, vehicle):
6311        return _pywrapcp.RoutingDimension_GetPreTravelEvaluatorOfVehicle(self, vehicle)
def GetPostTravelEvaluatorOfVehicle(self, vehicle):
6313    def GetPostTravelEvaluatorOfVehicle(self, vehicle):
6314        return _pywrapcp.RoutingDimension_GetPostTravelEvaluatorOfVehicle(self, vehicle)
def base_dimension(self):
6316    def base_dimension(self):
6317        r""" Returns the parent in the dependency tree if any or nullptr otherwise."""
6318        return _pywrapcp.RoutingDimension_base_dimension(self)

Returns the parent in the dependency tree if any or nullptr otherwise.

def ShortestTransitionSlack(self, node):
6320    def ShortestTransitionSlack(self, node):
6321        r"""
6322        It makes sense to use the function only for self-dependent dimension.
6323        For such dimensions the value of the slack of a node determines the
6324        transition cost of the next transit. Provided that
6325          1. cumul[node] is fixed,
6326          2. next[node] and next[next[node]] (if exists) are fixed,
6327        the value of slack[node] for which cumul[next[node]] + transit[next[node]]
6328        is minimized can be found in O(1) using this function.
6329        """
6330        return _pywrapcp.RoutingDimension_ShortestTransitionSlack(self, node)

It makes sense to use the function only for self-dependent dimension. For such dimensions the value of the slack of a node determines the transition cost of the next transit. Provided that

  1. cumul[node] is fixed,
  2. next[node] and next[next[node]] (if exists) are fixed, the value of slack[node] for which cumul[next[node]] + transit[next[node]] is minimized can be found in O(1) using this function.
def name(self):
6332    def name(self):
6333        r""" Returns the name of the dimension."""
6334        return _pywrapcp.RoutingDimension_name(self)

Returns the name of the dimension.

def SetPickupToDeliveryLimitFunctionForPair(self, limit_function, pair_index):
6336    def SetPickupToDeliveryLimitFunctionForPair(self, limit_function, pair_index):
6337        return _pywrapcp.RoutingDimension_SetPickupToDeliveryLimitFunctionForPair(self, limit_function, pair_index)
def HasPickupToDeliveryLimits(self):
6339    def HasPickupToDeliveryLimits(self):
6340        return _pywrapcp.RoutingDimension_HasPickupToDeliveryLimits(self)
def AddNodePrecedence(self, first_node, second_node, offset):
6342    def AddNodePrecedence(self, first_node, second_node, offset):
6343        return _pywrapcp.RoutingDimension_AddNodePrecedence(self, first_node, second_node, offset)
def GetSpanUpperBoundForVehicle(self, vehicle):
6345    def GetSpanUpperBoundForVehicle(self, vehicle):
6346        return _pywrapcp.RoutingDimension_GetSpanUpperBoundForVehicle(self, vehicle)
def GetSpanCostCoefficientForVehicle(self, vehicle):
6348    def GetSpanCostCoefficientForVehicle(self, vehicle):
6349        return _pywrapcp.RoutingDimension_GetSpanCostCoefficientForVehicle(self, vehicle)
def global_span_cost_coefficient(self):
6351    def global_span_cost_coefficient(self):
6352        return _pywrapcp.RoutingDimension_global_span_cost_coefficient(self)
def GetGlobalOptimizerOffset(self):
6354    def GetGlobalOptimizerOffset(self):
6355        return _pywrapcp.RoutingDimension_GetGlobalOptimizerOffset(self)
def GetLocalOptimizerOffsetForVehicle(self, vehicle):
6357    def GetLocalOptimizerOffsetForVehicle(self, vehicle):
6358        return _pywrapcp.RoutingDimension_GetLocalOptimizerOffsetForVehicle(self, vehicle)
def SetSoftSpanUpperBoundForVehicle(self, bound_cost, vehicle):
6360    def SetSoftSpanUpperBoundForVehicle(self, bound_cost, vehicle):
6361        r"""
6362        If the span of vehicle on this dimension is larger than bound,
6363        the cost will be increased by cost * (span - bound).
6364        """
6365        return _pywrapcp.RoutingDimension_SetSoftSpanUpperBoundForVehicle(self, bound_cost, vehicle)

If the span of vehicle on this dimension is larger than bound, the cost will be increased by cost * (span - bound).

def HasSoftSpanUpperBounds(self):
6367    def HasSoftSpanUpperBounds(self):
6368        return _pywrapcp.RoutingDimension_HasSoftSpanUpperBounds(self)
def GetSoftSpanUpperBoundForVehicle(self, vehicle):
6370    def GetSoftSpanUpperBoundForVehicle(self, vehicle):
6371        return _pywrapcp.RoutingDimension_GetSoftSpanUpperBoundForVehicle(self, vehicle)
def SetQuadraticCostSoftSpanUpperBoundForVehicle(self, bound_cost, vehicle):
6373    def SetQuadraticCostSoftSpanUpperBoundForVehicle(self, bound_cost, vehicle):
6374        r"""
6375        If the span of vehicle on this dimension is larger than bound,
6376        the cost will be increased by cost * (span - bound)^2.
6377        """
6378        return _pywrapcp.RoutingDimension_SetQuadraticCostSoftSpanUpperBoundForVehicle(self, bound_cost, vehicle)

If the span of vehicle on this dimension is larger than bound, the cost will be increased by cost * (span - bound)^2.

def HasQuadraticCostSoftSpanUpperBounds(self):
6380    def HasQuadraticCostSoftSpanUpperBounds(self):
6381        return _pywrapcp.RoutingDimension_HasQuadraticCostSoftSpanUpperBounds(self)
def GetQuadraticCostSoftSpanUpperBoundForVehicle(self, vehicle):
6383    def GetQuadraticCostSoftSpanUpperBoundForVehicle(self, vehicle):
6384        return _pywrapcp.RoutingDimension_GetQuadraticCostSoftSpanUpperBoundForVehicle(self, vehicle)
def MakeSetValuesFromTargets(solver, variables, targets):
6389def MakeSetValuesFromTargets(solver, variables, targets):
6390    r"""
6391    A decision builder which tries to assign values to variables as close as
6392    possible to target values first.
6393    """
6394    return _pywrapcp.MakeSetValuesFromTargets(solver, variables, targets)

A decision builder which tries to assign values to variables as close as possible to target values first.

def SolveModelWithSat(model, search_parameters, initial_solution, solution):
6396def SolveModelWithSat(model, search_parameters, initial_solution, solution):
6397    r"""
6398    Attempts to solve the model using the cp-sat solver. As of 5/2019, will
6399    solve the TSP corresponding to the model if it has a single vehicle.
6400    Therefore the resulting solution might not actually be feasible. Will return
6401    false if a solution could not be found.
6402    """
6403    return _pywrapcp.SolveModelWithSat(model, search_parameters, initial_solution, solution)

Attempts to solve the model using the cp-sat solver. As of 5/2019, will solve the TSP corresponding to the model if it has a single vehicle. Therefore the resulting solution might not actually be feasible. Will return false if a solution could not be found.